Autopsy 4.22.1
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-2021 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 */
19package org.sleuthkit.autopsy.datasourcesummary.ui;
20
21import java.text.DateFormat;
22import java.text.SimpleDateFormat;
23import java.util.ArrayList;
24import java.util.Arrays;
25import java.util.Date;
26import java.util.List;
27import java.util.Locale;
28import java.util.function.Function;
29import java.util.function.Supplier;
30import org.openide.util.NbBundle.Messages;
31import org.sleuthkit.autopsy.datasourcesummary.datamodel.RecentFilesSummary.RecentAttachmentDetails;
32import org.sleuthkit.autopsy.datasourcesummary.datamodel.RecentFilesSummary.RecentDownloadDetails;
33import org.sleuthkit.autopsy.datasourcesummary.datamodel.RecentFilesSummary.RecentFileDetails;
34import org.sleuthkit.autopsy.datasourcesummary.uiutils.CellModelTableCellRenderer;
35import org.sleuthkit.autopsy.datasourcesummary.uiutils.ColumnModel;
36import org.sleuthkit.autopsy.datasourcesummary.uiutils.DataFetchWorker;
37import org.sleuthkit.autopsy.datasourcesummary.datamodel.DataFetcher;
38import org.sleuthkit.autopsy.datasourcesummary.uiutils.DefaultCellModel;
39import org.sleuthkit.autopsy.datasourcesummary.uiutils.GuiCellModel.MenuItem;
40import org.sleuthkit.autopsy.datasourcesummary.uiutils.IngestRunningLabel;
41import org.sleuthkit.autopsy.datasourcesummary.uiutils.JTablePanel;
42import org.sleuthkit.autopsy.datasourcesummary.uiutils.ListTableModel;
43import org.sleuthkit.datamodel.DataSource;
44
48@Messages({
49 "RecentFilesPanel_docsTable_tabName=Recently Opened Documents",
50 "RecentFilesPanel_downloadsTable_tabName=Recent Downloads",
51 "RecentFilesPanel_attachmentsTable_tabName=Recent Attachments",})
52public final class RecentFilesPanel extends BaseDataSourceSummaryPanel {
53
54 private static final long serialVersionUID = 1L;
55 private static final String DATETIME_FORMAT_STR = "yyyy/MM/dd HH:mm:ss";
56 private static final DateFormat DATETIME_FORMAT = new SimpleDateFormat(DATETIME_FORMAT_STR, Locale.getDefault());
57
58 private final List<JTablePanel<?>> tablePanelList = new ArrayList<>();
59 private final List<DataFetchWorker.DataFetchComponents<DataSource, ?>> dataFetchComponents = new ArrayList<>();
60
62
66
67 private final List<ColumnModel<RecentFileDetails, DefaultCellModel<?>>> docsTemplate = Arrays.asList(
68 new ColumnModel<>(Bundle.RecentFilesPanel_col_header_path(),
69 (prog) -> {
70 return new DefaultCellModel<>(prog.getPath())
71 .setPopupMenuRetriever(getPopupFunct(prog));
72 }, 250),
73 new ColumnModel<>(Bundle.RecentFilesPanel_col_head_date(),
74 getDateFunct(),
75 80));
76
77 private final List<ColumnModel<RecentDownloadDetails, DefaultCellModel<?>>> downloadsTemplate = Arrays.asList(
78 new ColumnModel<>(Bundle.RecentFilesPanel_col_header_domain(),
79 (prog) -> {
80 return new DefaultCellModel<>(prog.getWebDomain())
81 .setPopupMenuRetriever(getPopupFunct(prog));
82 }, 100),
83 new ColumnModel<>(Bundle.RecentFilesPanel_col_header_path(),
84 (prog) -> {
85 return new DefaultCellModel<>(prog.getPath())
86 .setPopupMenuRetriever(getPopupFunct(prog));
87 }, 250),
88 new ColumnModel<>(Bundle.RecentFilesPanel_col_head_date(),
89 getDateFunct(),
90 80));
91
92 private final List<ColumnModel<RecentAttachmentDetails, DefaultCellModel<?>>> attachmentsTemplate = Arrays.asList(
93 new ColumnModel<>(Bundle.RecentFilesPanel_col_header_path(),
94 (prog) -> {
95 return new DefaultCellModel<>(prog.getPath())
96 .setPopupMenuRetriever(getPopupFunct(prog));
97 }, 250),
98 new ColumnModel<>(Bundle.RecentFilesPanel_col_head_date(),
99 getDateFunct(),
100 80),
101 new ColumnModel<>(Bundle.RecentFilesPanel_col_header_sender(),
102 (prog) -> {
103 return new DefaultCellModel<>(prog.getSender())
104 .setPopupMenuRetriever(getPopupFunct(prog));
105 }, 150));
106
110 @Messages({
111 "RecentFilesPanel_col_head_date=Date",
112 "RecentFilesPanel_col_header_domain=Domain",
113 "RecentFilesPanel_col_header_path=Path",
114 "RecentFilesPanel_col_header_sender=Sender"
115 })
117 this(new RecentFilesGetter());
118 }
119
124 super(dataHandler);
125 docsFetcher = (dataSource) -> dataHandler.getRecentlyOpenedDocuments(dataSource, 10);
126 downloadsFetcher = (dataSource) -> dataHandler.getRecentDownloads(dataSource, 10);
127 attachmentsFetcher = (dataSource) -> dataHandler.getRecentAttachments(dataSource, 10);
128
131 }
132
140 private <T extends RecentFileDetails> Function<T, DefaultCellModel<?>> getDateFunct() {
141 return (T lastAccessed) -> {
142 Function<Date, String> dateParser = (dt) -> dt == null ? "" : DATETIME_FORMAT.format(dt);
143 return new DefaultCellModel<>(new Date(lastAccessed.getDateAsLong() * 1000), dateParser)
144 .setPopupMenuRetriever(getPopupFunct(lastAccessed));
145 };
146 }
147
158 private Supplier<List<MenuItem>> getPopupFunct(RecentFileDetails record) {
159 return () -> {
160 if (record == null) {
161 return null;
162 }
163
164 List<MenuItem> toRet = new ArrayList<>();
165
166 MenuItem fileNav = getFileNavigateItem(record.getPath());
167 if (fileNav != null) {
168 toRet.add(fileNav);
169 }
170
171 if (record.getArtifact() != null) {
172 toRet.add(getArtifactNavigateItem(record.getArtifact()));
173 }
174
175 return (toRet.size() > 0) ? toRet : null;
176 };
177 }
178
179 @Override
180 protected void fetchInformation(DataSource dataSource) {
182 }
183
184 @Override
185 protected void onNewDataSource(DataSource dataSource) {
187 }
188
189 @Override
190 public void close() {
191 ingestRunningLabel.unregister();
192 super.close();
193 }
194
203
204 @Messages({
205 "RecentFilesPanel_no_open_documents=No recently open documents found."
206 })
210 @SuppressWarnings("unchecked")
211 private void initalizeOpenDocsTable() {
213
215 pane.setModel(tableModel);
217 pane.setKeyFunction((recentFile) -> recentFile.getPath());
219 tablePanelList.add(pane);
220
221 DataFetchWorker.DataFetchComponents<DataSource, List<RecentFileDetails>> worker
224 (result) -> pane.showDataFetchResult(result));
225
226 dataFetchComponents.add(worker);
227 }
228
232 @SuppressWarnings("unchecked")
233 private void initalizeDownloadTable() {
235
237 pane.setModel(tableModel);
238 pane.setKeyFunction((download) -> download.getPath());
241 tablePanelList.add(pane);
242
243 DataFetchWorker.DataFetchComponents<DataSource, List<RecentDownloadDetails>> worker
246 (result) -> pane.showDataFetchResult(result));
247
248 dataFetchComponents.add(worker);
249 }
250
254 @SuppressWarnings("unchecked")
257
259 pane.setModel(tableModel);
260 pane.setKeyFunction((attachment) -> attachment.getPath());
263 tablePanelList.add(pane);
264
265 DataFetchWorker.DataFetchComponents<DataSource, List<RecentAttachmentDetails>> worker
268 (result) -> pane.showDataFetchResult(result)
269 );
270
271 dataFetchComponents.add(worker);
272 }
273
279 @SuppressWarnings("unchecked")
280 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
281 private void initComponents() {
282 java.awt.GridBagConstraints gridBagConstraints;
283
284 javax.swing.JScrollPane scrollPane = new javax.swing.JScrollPane();
285 javax.swing.JPanel tablePanel = new javax.swing.JPanel();
286 javax.swing.JPanel ingestRunningPanel = ingestRunningLabel;
290 javax.swing.JLabel openDocsLabel = new javax.swing.JLabel();
291 javax.swing.JLabel downloadLabel = new javax.swing.JLabel();
292 javax.swing.JLabel attachmentLabel = new javax.swing.JLabel();
293 javax.swing.JLabel rightClickForMoreOptions1 = new javax.swing.JLabel();
294 javax.swing.JLabel rightClickForMoreOptions2 = new javax.swing.JLabel();
295 javax.swing.JLabel rightClickForMoreOptions3 = new javax.swing.JLabel();
296
297 setLayout(new java.awt.BorderLayout());
298
299 tablePanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10));
300 tablePanel.setMinimumSize(new java.awt.Dimension(400, 400));
301 tablePanel.setPreferredSize(new java.awt.Dimension(600, 400));
302 tablePanel.setLayout(new java.awt.GridBagLayout());
303
304 ingestRunningPanel.setAlignmentX(0.0F);
305 ingestRunningPanel.setMaximumSize(new java.awt.Dimension(32767, 25));
306 ingestRunningPanel.setMinimumSize(new java.awt.Dimension(10, 25));
307 ingestRunningPanel.setPreferredSize(new java.awt.Dimension(10, 25));
308 gridBagConstraints = new java.awt.GridBagConstraints();
309 gridBagConstraints.gridx = 0;
310 gridBagConstraints.gridy = 0;
311 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
312 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
313 tablePanel.add(ingestRunningPanel, gridBagConstraints);
314 gridBagConstraints = new java.awt.GridBagConstraints();
315 gridBagConstraints.gridx = 0;
316 gridBagConstraints.gridy = 2;
317 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
318 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
319 gridBagConstraints.weightx = 1.0;
320 gridBagConstraints.weighty = 1.0;
321 gridBagConstraints.insets = new java.awt.Insets(2, 0, 0, 0);
322 tablePanel.add(openedDocPane, gridBagConstraints);
323 gridBagConstraints = new java.awt.GridBagConstraints();
324 gridBagConstraints.gridx = 0;
325 gridBagConstraints.gridy = 5;
326 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
327 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
328 gridBagConstraints.weightx = 1.0;
329 gridBagConstraints.weighty = 1.0;
330 gridBagConstraints.insets = new java.awt.Insets(2, 0, 0, 0);
331 tablePanel.add(downloadsPane, gridBagConstraints);
332 gridBagConstraints = new java.awt.GridBagConstraints();
333 gridBagConstraints.gridx = 0;
334 gridBagConstraints.gridy = 8;
335 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
336 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
337 gridBagConstraints.weightx = 1.0;
338 gridBagConstraints.weighty = 1.0;
339 gridBagConstraints.insets = new java.awt.Insets(2, 0, 0, 0);
340 tablePanel.add(attachmentsPane, gridBagConstraints);
341
342 org.openide.awt.Mnemonics.setLocalizedText(openDocsLabel, org.openide.util.NbBundle.getMessage(RecentFilesPanel.class, "RecentFilesPanel.openDocsLabel.text")); // NOI18N
343 gridBagConstraints = new java.awt.GridBagConstraints();
344 gridBagConstraints.gridx = 0;
345 gridBagConstraints.gridy = 1;
346 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
347 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
348 tablePanel.add(openDocsLabel, gridBagConstraints);
349
350 org.openide.awt.Mnemonics.setLocalizedText(downloadLabel, org.openide.util.NbBundle.getMessage(RecentFilesPanel.class, "RecentFilesPanel.downloadLabel.text")); // NOI18N
351 gridBagConstraints = new java.awt.GridBagConstraints();
352 gridBagConstraints.gridx = 0;
353 gridBagConstraints.gridy = 4;
354 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
355 gridBagConstraints.insets = new java.awt.Insets(20, 0, 0, 0);
356 tablePanel.add(downloadLabel, gridBagConstraints);
357
358 org.openide.awt.Mnemonics.setLocalizedText(attachmentLabel, org.openide.util.NbBundle.getMessage(RecentFilesPanel.class, "RecentFilesPanel.attachmentLabel.text")); // NOI18N
359 gridBagConstraints = new java.awt.GridBagConstraints();
360 gridBagConstraints.gridx = 0;
361 gridBagConstraints.gridy = 7;
362 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
363 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
364 gridBagConstraints.insets = new java.awt.Insets(20, 0, 0, 0);
365 tablePanel.add(attachmentLabel, gridBagConstraints);
366
367 org.openide.awt.Mnemonics.setLocalizedText(rightClickForMoreOptions1, org.openide.util.NbBundle.getMessage(RecentFilesPanel.class, "RecentFilesPanel.rightClickForMoreOptions1.text")); // NOI18N
368 gridBagConstraints = new java.awt.GridBagConstraints();
369 gridBagConstraints.gridx = 0;
370 gridBagConstraints.gridy = 3;
371 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
372 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
373 tablePanel.add(rightClickForMoreOptions1, gridBagConstraints);
374
375 org.openide.awt.Mnemonics.setLocalizedText(rightClickForMoreOptions2, org.openide.util.NbBundle.getMessage(RecentFilesPanel.class, "RecentFilesPanel.rightClickForMoreOptions2.text")); // NOI18N
376 gridBagConstraints = new java.awt.GridBagConstraints();
377 gridBagConstraints.gridx = 0;
378 gridBagConstraints.gridy = 6;
379 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
380 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
381 tablePanel.add(rightClickForMoreOptions2, gridBagConstraints);
382
383 org.openide.awt.Mnemonics.setLocalizedText(rightClickForMoreOptions3, org.openide.util.NbBundle.getMessage(RecentFilesPanel.class, "RecentFilesPanel.rightClickForMoreOptions3.text")); // NOI18N
384 gridBagConstraints = new java.awt.GridBagConstraints();
385 gridBagConstraints.gridx = 0;
386 gridBagConstraints.gridy = 9;
387 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
388 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
389 tablePanel.add(rightClickForMoreOptions3, gridBagConstraints);
390
391 scrollPane.setViewportView(tablePanel);
392
393 add(scrollPane, java.awt.BorderLayout.CENTER);
394 }// </editor-fold>//GEN-END:initComponents
395
396
397 // Variables declaration - do not modify//GEN-BEGIN:variables
398 private javax.swing.JPanel attachmentsPane;
399 private javax.swing.JPanel downloadsPane;
400 private javax.swing.JPanel openedDocPane;
401 // End of variables declaration//GEN-END:variables
402}
List< RecentAttachmentDetails > getRecentAttachments(DataSource dataSource, int maxCount)
List< RecentDownloadDetails > getRecentDownloads(DataSource dataSource, int maxCount)
List< RecentFileDetails > getRecentlyOpenedDocuments(DataSource dataSource, int maxCount)
final List< ColumnModel< RecentAttachmentDetails, DefaultCellModel<?> > > attachmentsTemplate
final DataFetcher< DataSource, List< RecentFileDetails > > docsFetcher
final List< ColumnModel< RecentDownloadDetails, DefaultCellModel<?> > > downloadsTemplate
final List< DataFetchWorker.DataFetchComponents< DataSource, ?> > dataFetchComponents
final List< ColumnModel< RecentFileDetails, DefaultCellModel<?> > > docsTemplate
Supplier< List< MenuItem > > getPopupFunct(RecentFileDetails record)
final DataFetcher< DataSource, List< RecentDownloadDetails > > downloadsFetcher
final DataFetcher< DataSource, List< RecentAttachmentDetails > > attachmentsFetcher
void showDataFetchResult(DataFetchResult< T > result, String errorMessage, String noResultsMessage)
DefaultCellModel< T > setPopupMenuRetriever(Supplier< List< MenuItem > > menuItemSupplier)
JTablePanel< T > setColumnModel(TableColumnModel columnModel)
JTablePanel< T > setCellListener(CellMouseListener cellListener)
JTablePanel< T > setKeyFunction(Function< T, ? extends Object > keyFunction)
static< T, C extends GuiCellModel > ListTableModel< T > getTableModel(List< ColumnModel< T, C > > columns)
static< T, C extends GuiCellModel > TableColumnModel getTableColumnModel(List< ColumnModel< T, C > > columns)
final JTablePanel< T > setModel(ListTableModel< T > tableModel)

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.