19 package org.sleuthkit.autopsy.datasourcesummary.ui;
21 import java.awt.Component;
22 import java.text.DateFormat;
23 import java.text.SimpleDateFormat;
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 org.apache.commons.lang.StringUtils;
30 import org.openide.util.NbBundle.Messages;
51 "UserActivityPanel_tab_title=User Activity",
52 "UserActivityPanel_TopProgramsTableModel_tabName=Recent Programs",
53 "UserActivityPanel_TopDomainsTableModel_tabName=Recent Domains",
54 "UserActivityPanel_TopWebSearchTableModel_tabName=Recent Web Searches",
55 "UserActivityPanel_TopDeviceAttachedTableModel_tabName=Recent Devices Attached",
56 "UserActivityPanel_TopAccountTableModel_tabName=Recent Account Types Used",
57 "UserActivityPanel_TopProgramsTableModel_name_header=Program",
58 "UserActivityPanel_TopProgramsTableModel_folder_header=Folder",
59 "UserActivityPanel_TopProgramsTableModel_count_header=Run Times",
60 "UserActivityPanel_TopProgramsTableModel_lastrun_header=Last Run",
61 "UserActivityPanel_TopDomainsTableModel_domain_header=Domain",
62 "UserActivityPanel_TopDomainsTableModel_count_header=Visits",
63 "UserActivityPanel_TopDomainsTableModel_lastAccess_header=Last Accessed",
64 "UserActivityPanel_TopWebSearchTableModel_searchString_header=Search String",
65 "UserActivityPanel_TopWebSearchTableModel_dateAccessed_header=Date Accessed",
66 "UserActivityPanel_TopWebSearchTableModel_translatedResult_header=Translated",
67 "UserActivityPanel_TopDeviceAttachedTableModel_deviceId_header=Device Id",
68 "UserActivityPanel_TopDeviceAttachedTableModel_makeModel_header=Make and Model",
69 "UserActivityPanel_TopDeviceAttachedTableModel_dateAccessed_header=Last Accessed",
70 "UserActivityPanel_TopAccountTableModel_accountType_header=Account Type",
71 "UserActivityPanel_TopAccountTableModel_lastAccess_header=Last Accessed",
72 "UserActivityPanel_noDataExists=No communication data exists"})
75 private static final long serialVersionUID = 1L;
76 private static final String DATETIME_FORMAT_STR =
"yyyy/MM/dd HH:mm:ss";
77 private static final DateFormat DATETIME_FORMAT =
new SimpleDateFormat(DATETIME_FORMAT_STR, Locale.getDefault());
78 private static final int TOP_PROGS_COUNT = 10;
79 private static final int TOP_DOMAINS_COUNT = 10;
80 private static final int TOP_SEARCHES_COUNT = 10;
81 private static final int TOP_ACCOUNTS_COUNT = 5;
82 private static final int TOP_DEVICES_COUNT = 10;
85 private final List<ColumnModel<TopProgramsResult, DefaultCellModel<?>>> topProgramsTemplate = Arrays.asList(
88 Bundle.UserActivityPanel_TopProgramsTableModel_name_header(),
91 .setTooltip(prog.getProgramPath())
92 .setPopupMenu(getPopup(prog));
97 Bundle.UserActivityPanel_TopProgramsTableModel_folder_header(),
101 prog.getProgramPath(),
102 prog.getProgramName()))
104 .setPopupMenu(getPopup(prog));
109 Bundle.UserActivityPanel_TopProgramsTableModel_count_header(),
111 return new DefaultCellModel<>(prog.getRunTimes(), (num) -> num == null ?
"" : num.toString())
112 .setPopupMenu(getPopup(prog));
117 Bundle.UserActivityPanel_TopProgramsTableModel_lastrun_header(),
123 private final List<ColumnModel<TopDomainsResult, DefaultCellModel<?>>> topDomainsTemplate = Arrays.asList(
126 Bundle.UserActivityPanel_TopDomainsTableModel_domain_header(),
129 .setPopupMenu(getPopup(recentDomain));
134 Bundle.UserActivityPanel_TopDomainsTableModel_count_header(),
136 return new DefaultCellModel<>(recentDomain.getVisitTimes(), (num) -> num == null ?
"" : num.toString())
137 .setPopupMenu(getPopup(recentDomain));
142 Bundle.UserActivityPanel_TopDomainsTableModel_lastAccess_header(),
148 private final List<ColumnModel<TopWebSearchResult, DefaultCellModel<?>>> topWebSearchesTemplate = Arrays.asList(
151 Bundle.UserActivityPanel_TopWebSearchTableModel_searchString_header(),
154 .setPopupMenu(getPopup(webSearch));
160 Bundle.UserActivityPanel_TopWebSearchTableModel_dateAccessed_header(),
166 Bundle.UserActivityPanel_TopWebSearchTableModel_translatedResult_header(),
169 .setPopupMenu(getPopup(webSearch));
176 private final List<ColumnModel<TopDeviceAttachedResult, DefaultCellModel<?>>> topDevicesTemplate = Arrays.asList(
179 Bundle.UserActivityPanel_TopDeviceAttachedTableModel_deviceId_header(),
182 .setPopupMenu(getPopup(device));
188 Bundle.UserActivityPanel_TopDeviceAttachedTableModel_dateAccessed_header(),
194 Bundle.UserActivityPanel_TopDeviceAttachedTableModel_makeModel_header(),
196 String make = StringUtils.isBlank(device.getDeviceMake()) ?
"" : device.getDeviceMake().trim();
197 String model = StringUtils.isBlank(device.getDeviceModel()) ?
"" : device.getDeviceModel().trim();
198 String makeModelString = (make.isEmpty() || model.isEmpty())
200 : String.format(
"%s - %s", make, model);
202 .setPopupMenu(getPopup(device));
209 private final List<ColumnModel<TopAccountResult, DefaultCellModel<?>>> topAccountsTemplate = Arrays.asList(
212 Bundle.UserActivityPanel_TopAccountTableModel_accountType_header(),
215 .setPopupMenu(getPopup(account));
221 Bundle.UserActivityPanel_TopAccountTableModel_lastAccess_header(),
229 .setKeyFunction((prog) -> prog.getProgramPath() +
":" + prog.getProgramName());
233 .setKeyFunction((domain) -> domain.getDomain());
237 .setKeyFunction((query) -> query.getSearchString());
241 .setKeyFunction((topDevice) -> topDevice.getDeviceId());
245 .setKeyFunction((topAccount) -> topAccount.getAccountType());
253 private final List<JTablePanel<?>> tables = Arrays.asList(
257 topDevicesAttachedTable,
280 super(userActivityData);
281 this.userActivityData = userActivityData;
283 this.topProgramsFetcher = (dataSource) -> userActivityData.
getTopPrograms(dataSource, TOP_PROGS_COUNT);
284 this.topDomainsFetcher = (dataSource) -> userActivityData.
getRecentDomains(dataSource, TOP_DOMAINS_COUNT);
285 this.topWebSearchesFetcher = (dataSource) -> userActivityData.
getMostRecentWebSearches(dataSource, TOP_SEARCHES_COUNT);
286 this.topDevicesAttachedFetcher = (dataSource) -> userActivityData.
getRecentDevices(dataSource, TOP_DEVICES_COUNT);
287 this.topAccountsFetcher = (dataSource) -> userActivityData.
getRecentAccounts(dataSource, TOP_ACCOUNTS_COUNT);
290 this.dataFetchComponents = Arrays.asList(
301 topWebSearchesFetcher,
305 topDevicesAttachedFetcher,
316 private <T extends LastAccessedArtifact> Function<T, DefaultCellModel<?>> getDateFunct() {
317 return (T lastAccessed) -> {
318 Function<Date, String> dateParser = (dt) -> dt == null ?
"" : DATETIME_FORMAT.format(dt);
320 .setPopupMenu(getPopup(lastAccessed));
335 return record == null ? null : Arrays.asList(getArtifactNavigateItem(record.
getArtifact()));
352 fetchInformation(dataFetchComponents, dataSource);
357 onNewDataSource(dataFetchComponents, tables, dataSource);
371 @SuppressWarnings(
"unchecked")
373 private
void initComponents() {
375 javax.swing.JScrollPane contentScrollPane =
new javax.swing.JScrollPane();
376 javax.swing.JPanel contentPanel =
new javax.swing.JPanel();
377 javax.swing.JPanel ingestRunningPanel = ingestRunningLabel;
378 javax.swing.JLabel programsRunLabel =
new javax.swing.JLabel();
379 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));
380 javax.swing.JPanel topProgramsTablePanel = topProgramsTable;
381 javax.swing.JLabel rightClickForMoreOptions1 =
new javax.swing.JLabel();
382 javax.swing.Box.Filler filler3 =
new javax.swing.Box.Filler(
new java.awt.Dimension(0, 20),
new java.awt.Dimension(0, 20),
new java.awt.Dimension(0, 20));
383 javax.swing.JLabel recentDomainsLabel =
new javax.swing.JLabel();
384 javax.swing.Box.Filler filler2 =
new javax.swing.Box.Filler(
new java.awt.Dimension(0, 2),
new java.awt.Dimension(0, 2),
new java.awt.Dimension(0, 2));
385 javax.swing.JPanel recentDomainsTablePanel = recentDomainsTable;
386 javax.swing.JLabel rightClickForMoreOptions2 =
new javax.swing.JLabel();
387 javax.swing.Box.Filler filler4 =
new javax.swing.Box.Filler(
new java.awt.Dimension(0, 20),
new java.awt.Dimension(0, 20),
new java.awt.Dimension(0, 20));
388 javax.swing.JLabel topWebSearchLabel =
new javax.swing.JLabel();
389 javax.swing.Box.Filler filler5 =
new javax.swing.Box.Filler(
new java.awt.Dimension(0, 2),
new java.awt.Dimension(0, 2),
new java.awt.Dimension(0, 2));
390 javax.swing.JPanel topWebSearches = topWebSearchesTable;
391 javax.swing.JLabel rightClickForMoreOptions3 =
new javax.swing.JLabel();
392 javax.swing.Box.Filler filler6 =
new javax.swing.Box.Filler(
new java.awt.Dimension(0, 20),
new java.awt.Dimension(0, 20),
new java.awt.Dimension(0, 20));
393 javax.swing.JLabel topDevicesAttachedLabel =
new javax.swing.JLabel();
394 javax.swing.Box.Filler filler7 =
new javax.swing.Box.Filler(
new java.awt.Dimension(0, 2),
new java.awt.Dimension(0, 2),
new java.awt.Dimension(0, 2));
395 javax.swing.JPanel recentDevicesAttached = topDevicesAttachedTable;
396 javax.swing.JLabel rightClickForMoreOptions4 =
new javax.swing.JLabel();
397 javax.swing.Box.Filler filler8 =
new javax.swing.Box.Filler(
new java.awt.Dimension(0, 20),
new java.awt.Dimension(0, 20),
new java.awt.Dimension(0, 20));
398 javax.swing.JLabel recentAccountsLabel =
new javax.swing.JLabel();
399 javax.swing.Box.Filler filler9 =
new javax.swing.Box.Filler(
new java.awt.Dimension(0, 2),
new java.awt.Dimension(0, 2),
new java.awt.Dimension(0, 2));
400 javax.swing.JPanel topAccounts = topAccountsTable;
401 javax.swing.JLabel rightClickForMoreOptions5 =
new javax.swing.JLabel();
403 setLayout(
new java.awt.BorderLayout());
405 contentScrollPane.setMaximumSize(null);
406 contentScrollPane.setMinimumSize(null);
408 contentPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10));
409 contentPanel.setMaximumSize(
new java.awt.Dimension(32767, 450));
410 contentPanel.setMinimumSize(
new java.awt.Dimension(10, 450));
411 contentPanel.setLayout(
new javax.swing.BoxLayout(contentPanel, javax.swing.BoxLayout.PAGE_AXIS));
413 ingestRunningPanel.setAlignmentX(0.0F);
414 ingestRunningPanel.setMaximumSize(
new java.awt.Dimension(32767, 25));
415 ingestRunningPanel.setMinimumSize(
new java.awt.Dimension(10, 25));
416 ingestRunningPanel.setPreferredSize(
new java.awt.Dimension(10, 25));
417 contentPanel.add(ingestRunningPanel);
419 programsRunLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
420 org.openide.awt.Mnemonics.setLocalizedText(programsRunLabel,
org.openide.util.NbBundle.getMessage(
UserActivityPanel.class,
"UserActivityPanel.programsRunLabel.text"));
421 programsRunLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
422 contentPanel.add(programsRunLabel);
423 contentPanel.add(filler1);
425 topProgramsTablePanel.setAlignmentX(0.0F);
426 topProgramsTablePanel.setMaximumSize(
new java.awt.Dimension(32767, 106));
427 topProgramsTablePanel.setMinimumSize(
new java.awt.Dimension(10, 106));
428 topProgramsTablePanel.setPreferredSize(
new java.awt.Dimension(10, 106));
429 contentPanel.add(topProgramsTablePanel);
431 org.openide.awt.Mnemonics.setLocalizedText(rightClickForMoreOptions1,
org.openide.util.NbBundle.getMessage(
UserActivityPanel.class,
"UserActivityPanel.rightClickForMoreOptions1.text"));
432 contentPanel.add(rightClickForMoreOptions1);
433 contentPanel.add(filler3);
435 recentDomainsLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
436 org.openide.awt.Mnemonics.setLocalizedText(recentDomainsLabel,
org.openide.util.NbBundle.getMessage(
UserActivityPanel.class,
"UserActivityPanel.recentDomainsLabel.text"));
437 contentPanel.add(recentDomainsLabel);
438 contentPanel.add(filler2);
440 recentDomainsTablePanel.setAlignmentX(0.0F);
441 recentDomainsTablePanel.setMaximumSize(
new java.awt.Dimension(32767, 106));
442 recentDomainsTablePanel.setMinimumSize(
new java.awt.Dimension(10, 106));
443 recentDomainsTablePanel.setPreferredSize(
new java.awt.Dimension(10, 106));
444 contentPanel.add(recentDomainsTablePanel);
446 org.openide.awt.Mnemonics.setLocalizedText(rightClickForMoreOptions2,
org.openide.util.NbBundle.getMessage(
UserActivityPanel.class,
"UserActivityPanel.rightClickForMoreOptions2.text"));
447 contentPanel.add(rightClickForMoreOptions2);
448 contentPanel.add(filler4);
450 topWebSearchLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
451 org.openide.awt.Mnemonics.setLocalizedText(topWebSearchLabel,
org.openide.util.NbBundle.getMessage(
UserActivityPanel.class,
"UserActivityPanel.topWebSearchLabel.text"));
452 contentPanel.add(topWebSearchLabel);
453 contentPanel.add(filler5);
455 topWebSearches.setAlignmentX(0.0F);
456 topWebSearches.setMaximumSize(
new java.awt.Dimension(32767, 106));
457 topWebSearches.setMinimumSize(
new java.awt.Dimension(10, 106));
458 topWebSearches.setPreferredSize(
new java.awt.Dimension(10, 106));
459 contentPanel.add(topWebSearches);
461 org.openide.awt.Mnemonics.setLocalizedText(rightClickForMoreOptions3,
org.openide.util.NbBundle.getMessage(
UserActivityPanel.class,
"UserActivityPanel.rightClickForMoreOptions3.text"));
462 contentPanel.add(rightClickForMoreOptions3);
463 contentPanel.add(filler6);
465 topDevicesAttachedLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
466 org.openide.awt.Mnemonics.setLocalizedText(topDevicesAttachedLabel,
org.openide.util.NbBundle.getMessage(
UserActivityPanel.class,
"UserActivityPanel.topDevicesAttachedLabel.text"));
467 contentPanel.add(topDevicesAttachedLabel);
468 contentPanel.add(filler7);
470 recentDevicesAttached.setAlignmentX(0.0F);
471 recentDevicesAttached.setMaximumSize(
new java.awt.Dimension(32767, 106));
472 recentDevicesAttached.setMinimumSize(
new java.awt.Dimension(10, 106));
473 recentDevicesAttached.setPreferredSize(
new java.awt.Dimension(10, 106));
474 contentPanel.add(recentDevicesAttached);
476 org.openide.awt.Mnemonics.setLocalizedText(rightClickForMoreOptions4,
org.openide.util.NbBundle.getMessage(
UserActivityPanel.class,
"UserActivityPanel.rightClickForMoreOptions4.text"));
477 contentPanel.add(rightClickForMoreOptions4);
478 contentPanel.add(filler8);
480 recentAccountsLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
481 org.openide.awt.Mnemonics.setLocalizedText(recentAccountsLabel,
org.openide.util.NbBundle.getMessage(
UserActivityPanel.class,
"UserActivityPanel.recentAccountsLabel.text"));
482 contentPanel.add(recentAccountsLabel);
483 contentPanel.add(filler9);
485 topAccounts.setAlignmentX(0.0F);
486 topAccounts.setMaximumSize(
new java.awt.Dimension(32767, 106));
487 topAccounts.setMinimumSize(
new java.awt.Dimension(10, 106));
488 topAccounts.setPreferredSize(
new java.awt.Dimension(10, 106));
489 contentPanel.add(topAccounts);
491 org.openide.awt.Mnemonics.setLocalizedText(rightClickForMoreOptions5,
org.openide.util.NbBundle.getMessage(
UserActivityPanel.class,
"UserActivityPanel.rightClickForMoreOptions5.text"));
492 contentPanel.add(rightClickForMoreOptions5);
494 contentScrollPane.setViewportView(contentPanel);
496 add(contentScrollPane, java.awt.BorderLayout.CENTER);
List< TopProgramsResult > getTopPrograms(DataSource dataSource, int count)
void fetchInformation(DataSource dataSource)
final List< DataFetchComponents< DataSource,?> > dataFetchComponents
final UserActivitySummaryGetter userActivityData
final DataFetcher< DataSource, List< TopDeviceAttachedResult > > topDevicesAttachedFetcher
List< MenuItem > getPopup(LastAccessedArtifact record)
void onNewDataSource(DataSource dataSource)
final DataFetcher< DataSource, List< TopWebSearchResult > > topWebSearchesFetcher
final DataFetcher< DataSource, List< TopDomainsResult > > topDomainsFetcher
final DataFetcher< DataSource, List< TopProgramsResult > > topProgramsFetcher
void showDataFetchResult(DataFetchResult< T > result, String errorMessage, String noResultsMessage)
final DataFetcher< DataSource, List< TopAccountResult > > topAccountsFetcher
static< T, CextendsGuiCellModel > JTablePanel< T > getJTablePanel(List< ColumnModel< T, C >> columns)
List< TopAccountResult > getRecentAccounts(DataSource dataSource, int count)
List< TopWebSearchResult > getMostRecentWebSearches(DataSource dataSource, int count)
List< TopDeviceAttachedResult > getRecentDevices(DataSource dataSource, int count)
UserActivityPanel(UserActivitySummaryGetter userActivityData)
DefaultCellModel< T > setTooltip(String tooltip)
static String getShortFolderName(String path, String appName)
static String getShortFolderName(String strPath, String applicationName)
List< TopDomainsResult > getRecentDomains(DataSource dataSource, int count)
BlackboardArtifact getArtifact()