19 package org.sleuthkit.autopsy.datasourcesummary.ui;
21 import java.awt.CardLayout;
22 import java.awt.Component;
23 import java.beans.PropertyChangeListener;
24 import java.util.Arrays;
25 import java.util.EnumSet;
26 import java.util.List;
27 import java.util.function.Consumer;
28 import java.util.function.Function;
29 import org.openide.util.NbBundle.Messages;
41 "DataSourceSummaryTabbedPane_typesTab_title=Types",
42 "DataSourceSummaryTabbedPane_detailsTab_title=Container",
43 "DataSourceSummaryTabbedPane_userActivityTab_title=User Activity",
44 "DataSourceSummaryTabbedPane_ingestHistoryTab_title=Ingest History",
45 "DataSourceSummaryTabbedPane_recentFileTab_title=Recent Files",
46 "DataSourceSummaryTabbedPane_pastCasesTab_title=Past Cases",
47 "DataSourceSummaryTabbedPane_analysisTab_title=Analysis",
48 "DataSourceSummaryTabbedPane_geolocationTab_title=Geolocation",
49 "DataSourceSummaryTabbedPane_timelineTab_title=Timeline",
50 "DataSourceSummaryTabbedPane_exportTab_title=Export"
60 private final String tabTitle;
61 private final Component component;
62 private final Consumer<DataSource> onDataSource;
63 private final Function<DataSource, List<ExcelSheetExport>> excelExporter;
64 private final Runnable onClose;
65 private final Runnable onInit;
73 DataSourceTab(String tabTitle, BaseDataSourceSummaryPanel panel) {
74 this(tabTitle, panel, panel::setDataSource, panel::getExports, panel::close, panel::init);
75 panel.setParentCloseListener(() -> notifyParentClose());
92 DataSourceTab(String tabTitle, Component component, Consumer<DataSource> onDataSource,
93 Function<DataSource, List<ExcelSheetExport>> excelExporter, Runnable onClose,
95 this.tabTitle = tabTitle;
96 this.component = component;
97 this.onDataSource = onDataSource;
98 this.excelExporter = excelExporter;
99 this.onClose = onClose;
100 this.onInit = onInit;
114 Component getComponent() {
121 Consumer<DataSource> getOnDataSource() {
127 return excelExporter == null ? null : excelExporter.apply(dataSource);
146 private static final long serialVersionUID = 1L;
149 private static final String TABBED_PANE =
"tabbedPane";
150 private static final String NO_DATASOURCE_PANE =
"noDataSourcePane";
152 private Runnable notifyParentClose = null;
158 private final List<DataSourceTab> tabs = Arrays.asList(
159 new DataSourceTab(Bundle.DataSourceSummaryTabbedPane_typesTab_title(),
new TypesPanel()),
168 Bundle.DataSourceSummaryTabbedPane_ingestHistoryTab_title(),
170 ingestHistoryPanel::setDataSource,
171 IngestJobExcelExport::getExports,
174 new DataSourceTab(Bundle.DataSourceSummaryTabbedPane_detailsTab_title(),
new ContainerPanel()),
176 Bundle.DataSourceSummaryTabbedPane_exportTab_title(),
185 private final ExcelExportAction exportAction =
new ExcelExportAction(tabs);
187 private DataSource dataSource = null;
193 private final PropertyChangeListener caseEventsListener = (evt) -> {
212 if (notifyParentClose != null) {
213 notifyParentClose.run();
222 void setParentCloseListener(Runnable parentCloseAction) {
223 notifyParentClose = parentCloseAction;
231 cardLayout = (CardLayout) this.getLayout();
235 tabbedPane.addTab(tab.getTabTitle(), tab.getComponent());
238 Runnable onInitMethod = tab.getOnInit();
239 if (onInitMethod != null) {
245 cardLayout.show(
this, NO_DATASOURCE_PANE);
266 this.dataSource = dataSource;
269 if (tab.getOnDataSource() != null) {
270 tab.getOnDataSource().accept(dataSource);
274 if (this.dataSource == null) {
275 cardLayout.show(
this, NO_DATASOURCE_PANE);
277 cardLayout.show(
this, TABBED_PANE);
286 if (tab.getOnClose() != null) {
287 tab.getOnClose().run();
299 @SuppressWarnings(
"unchecked")
301 private
void initComponents() {
303 javax.swing.JPanel noDataSourcePane =
new javax.swing.JPanel();
304 javax.swing.JLabel noDataSourceLabel =
new javax.swing.JLabel();
305 javax.swing.JPanel tabContentPane =
new javax.swing.JPanel();
306 tabbedPane =
new javax.swing.JTabbedPane();
308 setLayout(
new java.awt.CardLayout());
310 noDataSourcePane.setLayout(
new java.awt.BorderLayout());
312 noDataSourceLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
313 org.openide.awt.Mnemonics.setLocalizedText(noDataSourceLabel,
org.openide.util.NbBundle.getMessage(
DataSourceSummaryTabbedPane.class,
"DataSourceSummaryTabbedPane.noDataSourceLabel.text"));
314 noDataSourcePane.add(noDataSourceLabel, java.awt.BorderLayout.CENTER);
316 add(noDataSourcePane,
"noDataSourcePane");
318 tabContentPane.setLayout(
new java.awt.BorderLayout());
319 tabContentPane.add(tabbedPane, java.awt.BorderLayout.CENTER);
321 add(tabContentPane,
"tabbedPane");
DataSourceSummaryTabbedPane()
void setDataSource(DataSource dataSource)
DataSource getDataSource()
List< ExcelSheetExport > getExcelExports(DataSource dataSource)
javax.swing.JTabbedPane tabbedPane
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
void setXlsxExportAction(Runnable onXlsxExport)
static void removeEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)