19 package org.sleuthkit.autopsy.datasourcesummary.ui;
21 import java.text.DateFormat;
22 import java.text.SimpleDateFormat;
23 import java.util.ArrayList;
24 import java.util.Arrays;
25 import java.util.Date;
26 import java.util.List;
27 import java.util.Locale;
28 import java.util.function.Function;
29 import java.util.function.Supplier;
30 import org.openide.util.NbBundle.Messages;
49 "RecentFilesPanel_docsTable_tabName=Recently Opened Documents",
50 "RecentFilesPanel_downloadsTable_tabName=Recent Downloads",
51 "RecentFilesPanel_attachmentsTable_tabName=Recent Attachments",})
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());
58 private final List<JTablePanel<?>> tablePanelList =
new ArrayList<>();
67 private final List<ColumnModel<RecentFileDetails, DefaultCellModel<?>>> docsTemplate = Arrays.asList(
71 .setPopupMenuRetriever(getPopupFunct(prog));
77 private final List<ColumnModel<RecentDownloadDetails, DefaultCellModel<?>>> downloadsTemplate = Arrays.asList(
78 new ColumnModel<>(Bundle.RecentFilesPanel_col_header_domain(),
81 .setPopupMenuRetriever(getPopupFunct(prog));
86 .setPopupMenuRetriever(getPopupFunct(prog));
88 new ColumnModel<>(Bundle.RecentFilesPanel_col_head_date(),
92 private final List<ColumnModel<RecentAttachmentDetails, DefaultCellModel<?>>> attachmentsTemplate = Arrays.asList(
96 .setPopupMenuRetriever(getPopupFunct(prog));
101 new ColumnModel<>(Bundle.RecentFilesPanel_col_header_sender(),
104 .setPopupMenuRetriever(getPopupFunct(prog));
111 "RecentFilesPanel_col_head_date=Date",
112 "RecentFilesPanel_col_header_domain=Domain",
113 "RecentFilesPanel_col_header_path=Path",
114 "RecentFilesPanel_col_header_sender=Sender"
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)
160 if (record == null) {
164 List<MenuItem> toRet =
new ArrayList<>();
167 if (fileNav != null) {
172 toRet.add(getArtifactNavigateItem(record.
getArtifact()));
175 return (toRet.size() > 0) ? toRet : null;
181 fetchInformation(dataFetchComponents, dataSource);
186 onNewDataSource(dataFetchComponents, tablePanelList, dataSource);
199 initalizeOpenDocsTable();
200 initalizeDownloadTable();
201 initalizeAttchementsTable();
205 "RecentFilesPanel_no_open_documents=No recently open documents found."
210 @SuppressWarnings(
"unchecked")
211 private
void initalizeOpenDocsTable() {
219 tablePanelList.add(pane);
226 dataFetchComponents.add(worker);
232 @SuppressWarnings(
"unchecked")
233 private
void initalizeDownloadTable() {
241 tablePanelList.add(pane);
248 dataFetchComponents.add(worker);
254 @SuppressWarnings(
"unchecked")
255 private
void initalizeAttchementsTable() {
263 tablePanelList.add(pane);
271 dataFetchComponents.add(worker);
279 @SuppressWarnings(
"unchecked")
281 private
void initComponents() {
282 java.awt.GridBagConstraints gridBagConstraints;
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();
297 setLayout(
new java.awt.BorderLayout());
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());
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);
342 org.openide.awt.Mnemonics.setLocalizedText(openDocsLabel,
org.openide.util.NbBundle.getMessage(
RecentFilesPanel.class,
"RecentFilesPanel.openDocsLabel.text"));
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);
350 org.openide.awt.Mnemonics.setLocalizedText(downloadLabel,
org.openide.util.NbBundle.getMessage(
RecentFilesPanel.class,
"RecentFilesPanel.downloadLabel.text"));
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);
358 org.openide.awt.Mnemonics.setLocalizedText(attachmentLabel,
org.openide.util.NbBundle.getMessage(
RecentFilesPanel.class,
"RecentFilesPanel.attachmentLabel.text"));
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);
367 org.openide.awt.Mnemonics.setLocalizedText(rightClickForMoreOptions1,
org.openide.util.NbBundle.getMessage(
RecentFilesPanel.class,
"RecentFilesPanel.rightClickForMoreOptions1.text"));
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);
375 org.openide.awt.Mnemonics.setLocalizedText(rightClickForMoreOptions2,
org.openide.util.NbBundle.getMessage(
RecentFilesPanel.class,
"RecentFilesPanel.rightClickForMoreOptions2.text"));
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);
383 org.openide.awt.Mnemonics.setLocalizedText(rightClickForMoreOptions3,
org.openide.util.NbBundle.getMessage(
RecentFilesPanel.class,
"RecentFilesPanel.rightClickForMoreOptions3.text"));
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);
391 scrollPane.setViewportView(tablePanel);
393 add(scrollPane, java.awt.BorderLayout.CENTER);
JTablePanel< T > setColumnModel(TableColumnModel columnModel)
static< T, CextendsGuiCellModel > TableColumnModel getTableColumnModel(List< ColumnModel< T, C >> columns)
final DataFetcher< DataSource, List< RecentAttachmentDetails > > attachmentsFetcher
DefaultCellModel< T > setPopupMenuRetriever(Supplier< List< MenuItem >> menuItemSupplier)
javax.swing.JPanel openedDocPane
Supplier< List< MenuItem > > getPopupFunct(RecentFileDetails record)
void showDataFetchResult(DataFetchResult< T > result, String errorMessage, String noResultsMessage)
BlackboardArtifact getArtifact()
javax.swing.JPanel downloadsPane
static< T, CextendsGuiCellModel > ListTableModel< T > getTableModel(List< ColumnModel< T, C >> columns)
final DataFetcher< DataSource, List< RecentFileDetails > > docsFetcher
JTablePanel< T > setCellListener(CellMouseListener cellListener)
RecentFilesPanel(RecentFilesGetter dataHandler)
final DataFetcher< DataSource, List< RecentDownloadDetails > > downloadsFetcher
void fetchInformation(DataSource dataSource)
javax.swing.JPanel attachmentsPane
List< RecentDownloadDetails > getRecentDownloads(DataSource dataSource, int maxCount)
void onNewDataSource(DataSource dataSource)
List< RecentAttachmentDetails > getRecentAttachments(DataSource dataSource, int maxCount)
List< RecentFileDetails > getRecentlyOpenedDocuments(DataSource dataSource, int maxCount)
static CellMouseListener getMouseListener()
final JTablePanel< T > setModel(ListTableModel< T > tableModel)
JTablePanel< T > setKeyFunction(Function< T,?extends Object > keyFunction)