Autopsy  4.16.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
DataSourceSummaryTabbedPane.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2020 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  */
19 package org.sleuthkit.autopsy.datasourcesummary.ui;
20 
21 import java.awt.Component;
22 import java.util.Arrays;
23 import java.util.List;
24 import java.util.function.Consumer;
25 import javax.swing.JTabbedPane;
26 import org.openide.util.NbBundle.Messages;
28 import org.sleuthkit.datamodel.DataSource;
29 
34 @Messages({
35  "DataSourceSummaryTabbedPane_typesTab_title=Types",
36  "DataSourceSummaryTabbedPane_detailsTab_title=Container",
37  "DataSourceSummaryTabbedPane_userActivityTab_title=User Activity",
38  "DataSourceSummaryTabbedPane_ingestHistoryTab_title=Ingest History",
39  "DataSourceSummaryTabbedPane_recentFileTab_title=Recent Files",
40  "DataSourceSummaryTabbedPane_pastCasesTab_title=Past Cases",
41  "DataSourceSummaryTabbedPane_analysisTab_title=Analysis"
42 })
43 public class DataSourceSummaryTabbedPane extends JTabbedPane {
44 
49  private static class DataSourceTab {
50 
51  private final String tabTitle;
52  private final Component component;
53  private final Consumer<DataSource> onDataSource;
54  private final Runnable onClose;
55 
64  DataSourceTab(String tabTitle, Component component, Consumer<DataSource> onDataSource, Runnable onClose) {
65  this.tabTitle = tabTitle;
66  this.component = component;
67  this.onDataSource = onDataSource;
68  this.onClose = onClose;
69  }
70 
77  DataSourceTab(String tabTitle, BaseDataSourceSummaryPanel panel) {
78  this.tabTitle = tabTitle;
79  this.component = panel;
80  this.onDataSource = panel::setDataSource;
81  this.onClose = panel::close;
82  }
83 
87  String getTabTitle() {
88  return tabTitle;
89  }
90 
94  Component getComponent() {
95  return component;
96  }
97 
101  Consumer<DataSource> getOnDataSource() {
102  return onDataSource;
103  }
104 
108  public Runnable getOnClose() {
109  return onClose;
110  }
111  }
112 
113  private static final long serialVersionUID = 1L;
114 
115  private final IngestJobInfoPanel ingestHistoryPanel = new IngestJobInfoPanel();
116 
117  private final List<DataSourceTab> tabs = Arrays.asList(
118  new DataSourceTab(Bundle.DataSourceSummaryTabbedPane_typesTab_title(), new TypesPanel()),
119  new DataSourceTab(Bundle.DataSourceSummaryTabbedPane_userActivityTab_title(), new UserActivityPanel()),
120  new DataSourceTab(Bundle.DataSourceSummaryTabbedPane_analysisTab_title(), new AnalysisPanel()),
121  new DataSourceTab(Bundle.DataSourceSummaryTabbedPane_recentFileTab_title(), new RecentFilesPanel()),
122  new DataSourceTab(Bundle.DataSourceSummaryTabbedPane_pastCasesTab_title(), new PastCasesPanel()),
123  // do nothing on closing
124  new DataSourceTab(Bundle.DataSourceSummaryTabbedPane_ingestHistoryTab_title(), ingestHistoryPanel, ingestHistoryPanel::setDataSource, () -> {
125  }),
126  new DataSourceTab(Bundle.DataSourceSummaryTabbedPane_detailsTab_title(), new ContainerPanel())
127  );
128 
129  private DataSource dataSource = null;
130 
135  initComponent();
136  }
137 
138  private void initComponent() {
139  for (DataSourceTab tab : tabs) {
140  addTab(tab.getTabTitle(), tab.getComponent());
141  }
142  }
143 
149  public DataSource getDataSource() {
150  return dataSource;
151  }
152 
158  public void setDataSource(DataSource dataSource) {
159  this.dataSource = dataSource;
160 
161  for (DataSourceTab tab : tabs) {
162  tab.getOnDataSource().accept(dataSource);
163  }
164  }
165 
169  public void close() {
170  for (DataSourceTab tab : tabs) {
171  tab.getOnClose().run();
172  }
173  }
174 }

Copyright © 2012-2020 Basis Technology. Generated on: Tue Sep 22 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.