Autopsy  4.17.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 java.util.function.Supplier;
25 import org.openide.util.NbBundle.Messages;
38 import org.sleuthkit.datamodel.DataSource;
39 
43 public final class RecentFilesPanel extends BaseDataSourceSummaryPanel {
44 
45  private static final long serialVersionUID = 1L;
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 
89  private Supplier<List<MenuItem>> getPopupFunct(RecentFileDetails record) {
90  return () -> {
91  if (record == null) {
92  return null;
93  }
94 
95  List<MenuItem> toRet = new ArrayList<>();
96 
97  MenuItem fileNav = getFileNavigateItem(record.getPath());
98  if (fileNav != null) {
99  toRet.add(fileNav);
100  }
101 
102  if (record.getArtifact() != null) {
103  toRet.add(getArtifactNavigateItem(record.getArtifact()));
104  }
105 
106  return (toRet.size() > 0) ? toRet : null;
107  };
108  }
109 
110  @Override
111  protected void fetchInformation(DataSource dataSource) {
112  fetchInformation(dataFetchComponents, dataSource);
113  }
114 
115  @Override
116  protected void onNewDataSource(DataSource dataSource) {
117  onNewDataSource(dataFetchComponents, tablePanelList, dataSource);
118  }
119 
120  @Override
121  public void close() {
122  ingestRunningLabel.unregister();
123  super.close();
124  }
125 
129  private void initalizeTables() {
133  }
134 
135  @Messages({
136  "RecentFilePanel_no_open_documents=No recently open documents found."
137  })
141  @SuppressWarnings("unchecked")
142  private void initalizeOpenDocsTable() {
143  List<ColumnModel<RecentFileDetails>> list = Arrays.asList(
144  new ColumnModel<>(Bundle.RecentFilePanel_col_header_path(),
145  (prog) -> {
146  return new DefaultCellModel(prog.getPath())
147  .setPopupMenuRetriever(getPopupFunct(prog));
148  }, 250),
149  new ColumnModel<>(Bundle.RecentFilesPanel_col_head_date(),
150  (prog) -> {
151  return new DefaultCellModel(prog.getDateAsString())
152  .setPopupMenuRetriever(getPopupFunct(prog));
153  }, 80));
154 
156 
158  pane.setModel(tableModel);
160  pane.setKeyFunction((recentFile) -> recentFile.getPath());
162  tablePanelList.add(pane);
163 
164  DataFetchWorker.DataFetchComponents<DataSource, List<RecentFileDetails>> worker
166  (dataSource) -> dataHandler.getRecentlyOpenedDocuments(dataSource, 10),
167  (result) -> pane.showDataFetchResult(result));
168 
169  dataFetchComponents.add(worker);
170  }
171 
175  @SuppressWarnings("unchecked")
176  private void initalizeDownloadTable() {
177  List<ColumnModel<RecentDownloadDetails>> list = Arrays.asList(
178  new ColumnModel<>(Bundle.RecentFilePanel_col_header_domain(),
179  (prog) -> {
180  return new DefaultCellModel(prog.getWebDomain())
181  .setPopupMenuRetriever(getPopupFunct(prog));
182  }, 100),
183  new ColumnModel<>(Bundle.RecentFilePanel_col_header_path(),
184  (prog) -> {
185  return new DefaultCellModel(prog.getPath())
186  .setPopupMenuRetriever(getPopupFunct(prog));
187  }, 250),
188  new ColumnModel<>(Bundle.RecentFilesPanel_col_head_date(),
189  (prog) -> {
190  return new DefaultCellModel(prog.getDateAsString())
191  .setPopupMenuRetriever(getPopupFunct(prog));
192  }, 80));
193 
195 
197  pane.setModel(tableModel);
198  pane.setKeyFunction((download) -> download.getPath());
201  tablePanelList.add(pane);
202 
203  DataFetchWorker.DataFetchComponents<DataSource, List<RecentDownloadDetails>> worker
205  (dataSource) -> dataHandler.getRecentDownloads(dataSource, 10),
206  (result) -> pane.showDataFetchResult(result));
207 
208  dataFetchComponents.add(worker);
209  }
210 
214  @SuppressWarnings("unchecked")
215  private void initalizeAttchementsTable() {
216  List<ColumnModel<RecentAttachmentDetails>> list = Arrays.asList(
217  new ColumnModel<>(Bundle.RecentFilePanel_col_header_path(),
218  (prog) -> {
219  return new DefaultCellModel(prog.getPath())
220  .setPopupMenuRetriever(getPopupFunct(prog));
221  }, 250),
222  new ColumnModel<>(Bundle.RecentFilesPanel_col_head_date(),
223  (prog) -> {
224  return new DefaultCellModel(prog.getDateAsString())
225  .setPopupMenuRetriever(getPopupFunct(prog));
226  }, 80),
227  new ColumnModel<>(Bundle.RecentFilePanel_col_header_sender(),
228  (prog) -> {
229  return new DefaultCellModel(prog.getSender())
230  .setPopupMenuRetriever(getPopupFunct(prog));
231  }, 150));
232 
234 
236  pane.setModel(tableModel);
237  pane.setKeyFunction((attachment) -> attachment.getPath());
240  tablePanelList.add(pane);
241 
242  DataFetchWorker.DataFetchComponents<DataSource, List<RecentAttachmentDetails>> worker
244  (dataSource) -> dataHandler.getRecentAttachments(dataSource, 10),
245  (result) -> pane.showDataFetchResult(result)
246  );
247 
248  dataFetchComponents.add(worker);
249  }
250 
256  @SuppressWarnings("unchecked")
257  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
258  private void initComponents() {
259  java.awt.GridBagConstraints gridBagConstraints;
260 
261  javax.swing.JScrollPane scrollPane = new javax.swing.JScrollPane();
262  javax.swing.JPanel tablePanel = new javax.swing.JPanel();
263  javax.swing.JPanel ingestRunningPanel = ingestRunningLabel;
267  javax.swing.JLabel openDocsLabel = new javax.swing.JLabel();
268  javax.swing.JLabel downloadLabel = new javax.swing.JLabel();
269  javax.swing.JLabel attachmentLabel = new javax.swing.JLabel();
270  javax.swing.JLabel rightClickForMoreOptions1 = new javax.swing.JLabel();
271  javax.swing.JLabel rightClickForMoreOptions2 = new javax.swing.JLabel();
272  javax.swing.JLabel rightClickForMoreOptions3 = new javax.swing.JLabel();
273 
274  setLayout(new java.awt.BorderLayout());
275 
276  tablePanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10));
277  tablePanel.setMinimumSize(new java.awt.Dimension(400, 400));
278  tablePanel.setPreferredSize(new java.awt.Dimension(600, 400));
279  tablePanel.setLayout(new java.awt.GridBagLayout());
280 
281  ingestRunningPanel.setAlignmentX(0.0F);
282  ingestRunningPanel.setMaximumSize(new java.awt.Dimension(32767, 25));
283  ingestRunningPanel.setMinimumSize(new java.awt.Dimension(10, 25));
284  ingestRunningPanel.setPreferredSize(new java.awt.Dimension(10, 25));
285  gridBagConstraints = new java.awt.GridBagConstraints();
286  gridBagConstraints.gridx = 0;
287  gridBagConstraints.gridy = 0;
288  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
289  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
290  tablePanel.add(ingestRunningPanel, gridBagConstraints);
291  gridBagConstraints = new java.awt.GridBagConstraints();
292  gridBagConstraints.gridx = 0;
293  gridBagConstraints.gridy = 2;
294  gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
295  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
296  gridBagConstraints.weightx = 1.0;
297  gridBagConstraints.weighty = 1.0;
298  gridBagConstraints.insets = new java.awt.Insets(2, 0, 0, 0);
299  tablePanel.add(openedDocPane, gridBagConstraints);
300  gridBagConstraints = new java.awt.GridBagConstraints();
301  gridBagConstraints.gridx = 0;
302  gridBagConstraints.gridy = 5;
303  gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
304  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
305  gridBagConstraints.weightx = 1.0;
306  gridBagConstraints.weighty = 1.0;
307  gridBagConstraints.insets = new java.awt.Insets(2, 0, 0, 0);
308  tablePanel.add(downloadsPane, gridBagConstraints);
309  gridBagConstraints = new java.awt.GridBagConstraints();
310  gridBagConstraints.gridx = 0;
311  gridBagConstraints.gridy = 8;
312  gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
313  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
314  gridBagConstraints.weightx = 1.0;
315  gridBagConstraints.weighty = 1.0;
316  gridBagConstraints.insets = new java.awt.Insets(2, 0, 0, 0);
317  tablePanel.add(attachmentsPane, gridBagConstraints);
318 
319  org.openide.awt.Mnemonics.setLocalizedText(openDocsLabel, org.openide.util.NbBundle.getMessage(RecentFilesPanel.class, "RecentFilesPanel.openDocsLabel.text")); // NOI18N
320  gridBagConstraints = new java.awt.GridBagConstraints();
321  gridBagConstraints.gridx = 0;
322  gridBagConstraints.gridy = 1;
323  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
324  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
325  tablePanel.add(openDocsLabel, gridBagConstraints);
326 
327  org.openide.awt.Mnemonics.setLocalizedText(downloadLabel, org.openide.util.NbBundle.getMessage(RecentFilesPanel.class, "RecentFilesPanel.downloadLabel.text")); // NOI18N
328  gridBagConstraints = new java.awt.GridBagConstraints();
329  gridBagConstraints.gridx = 0;
330  gridBagConstraints.gridy = 4;
331  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
332  gridBagConstraints.insets = new java.awt.Insets(20, 0, 0, 0);
333  tablePanel.add(downloadLabel, gridBagConstraints);
334 
335  org.openide.awt.Mnemonics.setLocalizedText(attachmentLabel, org.openide.util.NbBundle.getMessage(RecentFilesPanel.class, "RecentFilesPanel.attachmentLabel.text")); // NOI18N
336  gridBagConstraints = new java.awt.GridBagConstraints();
337  gridBagConstraints.gridx = 0;
338  gridBagConstraints.gridy = 7;
339  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
340  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
341  gridBagConstraints.insets = new java.awt.Insets(20, 0, 0, 0);
342  tablePanel.add(attachmentLabel, gridBagConstraints);
343 
344  org.openide.awt.Mnemonics.setLocalizedText(rightClickForMoreOptions1, org.openide.util.NbBundle.getMessage(RecentFilesPanel.class, "RecentFilesPanel.rightClickForMoreOptions1.text")); // NOI18N
345  gridBagConstraints = new java.awt.GridBagConstraints();
346  gridBagConstraints.gridx = 0;
347  gridBagConstraints.gridy = 3;
348  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
349  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
350  tablePanel.add(rightClickForMoreOptions1, gridBagConstraints);
351 
352  org.openide.awt.Mnemonics.setLocalizedText(rightClickForMoreOptions2, org.openide.util.NbBundle.getMessage(RecentFilesPanel.class, "RecentFilesPanel.rightClickForMoreOptions2.text")); // NOI18N
353  gridBagConstraints = new java.awt.GridBagConstraints();
354  gridBagConstraints.gridx = 0;
355  gridBagConstraints.gridy = 6;
356  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
357  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
358  tablePanel.add(rightClickForMoreOptions2, gridBagConstraints);
359 
360  org.openide.awt.Mnemonics.setLocalizedText(rightClickForMoreOptions3, org.openide.util.NbBundle.getMessage(RecentFilesPanel.class, "RecentFilesPanel.rightClickForMoreOptions3.text")); // NOI18N
361  gridBagConstraints = new java.awt.GridBagConstraints();
362  gridBagConstraints.gridx = 0;
363  gridBagConstraints.gridy = 9;
364  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
365  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
366  tablePanel.add(rightClickForMoreOptions3, gridBagConstraints);
367 
368  scrollPane.setViewportView(tablePanel);
369 
370  add(scrollPane, java.awt.BorderLayout.CENTER);
371  }// </editor-fold>//GEN-END:initComponents
372 
373 
374  // Variables declaration - do not modify//GEN-BEGIN:variables
375  private javax.swing.JPanel attachmentsPane;
376  private javax.swing.JPanel downloadsPane;
377  private javax.swing.JPanel openedDocPane;
378  // End of variables declaration//GEN-END:variables
379 }
JTablePanel< T > setColumnModel(TableColumnModel columnModel)
List< RecentFileDetails > getRecentlyOpenedDocuments(DataSource dataSource, int maxCount)
Supplier< List< MenuItem > > getPopupFunct(RecentFileDetails record)
void showDataFetchResult(DataFetchResult< T > result, String errorMessage, String noResultsMessage)
List< RecentDownloadDetails > getRecentDownloads(DataSource dataSource, int maxCount)
JTablePanel< T > setCellListener(CellMouseListener cellListener)
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-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.