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 org.openide.util.NbBundle.Messages;
38 "DataSourceSummaryTabbedPane_typesTab_title=Types",
39 "DataSourceSummaryTabbedPane_detailsTab_title=Container",
40 "DataSourceSummaryTabbedPane_userActivityTab_title=User Activity",
41 "DataSourceSummaryTabbedPane_ingestHistoryTab_title=Ingest History",
42 "DataSourceSummaryTabbedPane_recentFileTab_title=Recent Files",
43 "DataSourceSummaryTabbedPane_pastCasesTab_title=Past Cases",
44 "DataSourceSummaryTabbedPane_analysisTab_title=Analysis",
45 "DataSourceSummaryTabbedPane_geolocationTab_title=Geolocation",
46 "DataSourceSummaryTabbedPane_timelineTab_title=Timeline"
56 private final String tabTitle;
57 private final Component component;
58 private final Consumer<DataSource> onDataSource;
59 private final Runnable onClose;
60 private final Runnable onInit;
68 DataSourceTab(String tabTitle, BaseDataSourceSummaryPanel panel) {
69 this(tabTitle, panel, panel::setDataSource, panel::close, panel::init);
70 panel.setParentCloseListener(() -> notifyParentClose());
87 DataSourceTab(String tabTitle, Component component, Consumer<DataSource> onDataSource,
88 Runnable onClose, Runnable onInit) {
89 this.tabTitle = tabTitle;
90 this.component = component;
91 this.onDataSource = onDataSource;
92 this.onClose = onClose;
106 Component getComponent() {
113 Consumer<DataSource> getOnDataSource() {
133 private static final long serialVersionUID = 1L;
136 private static final String TABBED_PANE =
"tabbedPane";
137 private static final String NO_DATASOURCE_PANE =
"noDataSourcePane";
139 private Runnable notifyParentClose = null;
142 private final List<DataSourceTab> tabs = Arrays.asList(
143 new DataSourceTab(Bundle.DataSourceSummaryTabbedPane_typesTab_title(),
new TypesPanel()),
152 Bundle.DataSourceSummaryTabbedPane_ingestHistoryTab_title(),
154 ingestHistoryPanel::setDataSource,
157 new DataSourceTab(Bundle.DataSourceSummaryTabbedPane_detailsTab_title(),
new ContainerPanel())
160 private DataSource dataSource = null;
166 private final PropertyChangeListener caseEventsListener = (evt) -> {
185 if (notifyParentClose != null) {
186 notifyParentClose.run();
195 void setParentCloseListener(Runnable parentCloseAction) {
196 notifyParentClose = parentCloseAction;
204 cardLayout = (CardLayout) this.getLayout();
208 tabbedPane.addTab(tab.getTabTitle(), tab.getComponent());
211 Runnable onInitMethod = tab.getOnInit();
212 if (onInitMethod != null) {
218 cardLayout.show(
this, NO_DATASOURCE_PANE);
236 this.dataSource = dataSource;
239 if (tab.getOnDataSource() != null) {
240 tab.getOnDataSource().accept(dataSource);
244 if (this.dataSource == null) {
245 cardLayout.show(
this, NO_DATASOURCE_PANE);
247 cardLayout.show(
this, TABBED_PANE);
256 if (tab.getOnClose() != null) {
257 tab.getOnClose().run();
269 @SuppressWarnings(
"unchecked")
271 private
void initComponents() {
273 javax.swing.JPanel noDataSourcePane =
new javax.swing.JPanel();
274 javax.swing.JLabel noDataSourceLabel =
new javax.swing.JLabel();
275 javax.swing.JPanel tabContentPane =
new javax.swing.JPanel();
276 tabbedPane =
new javax.swing.JTabbedPane();
278 setLayout(
new java.awt.CardLayout());
280 noDataSourcePane.setLayout(
new java.awt.BorderLayout());
282 noDataSourceLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
283 org.openide.awt.Mnemonics.setLocalizedText(noDataSourceLabel,
org.openide.util.NbBundle.getMessage(
DataSourceSummaryTabbedPane.class,
"DataSourceSummaryTabbedPane.noDataSourceLabel.text"));
284 noDataSourcePane.add(noDataSourceLabel, java.awt.BorderLayout.CENTER);
286 add(noDataSourcePane,
"noDataSourcePane");
288 tabContentPane.setLayout(
new java.awt.BorderLayout());
289 tabContentPane.add(tabbedPane, java.awt.BorderLayout.CENTER);
291 add(tabContentPane,
"tabbedPane");
DataSourceSummaryTabbedPane()
void setDataSource(DataSource dataSource)
DataSource getDataSource()
javax.swing.JTabbedPane tabbedPane
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
static void removeEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)