19 package org.sleuthkit.autopsy.datasourcesummary.ui;
21 import java.awt.Frame;
22 import java.beans.PropertyChangeEvent;
23 import java.beans.PropertyChangeListener;
24 import java.util.EnumSet;
26 import java.util.Observable;
27 import java.util.Observer;
29 import javax.swing.WindowConstants;
30 import javax.swing.event.ListSelectionEvent;
31 import org.openide.util.NbBundle.Messages;
42 final class DataSourceSummaryDialog
extends javax.swing.JDialog implements Observer {
44 private static final long serialVersionUID = 1L;
45 private static final Set<IngestManager.IngestJobEvent> INGEST_JOB_EVENTS_OF_INTEREST = EnumSet.of(IngestManager.IngestJobEvent.DATA_SOURCE_ANALYSIS_COMPLETED);
46 private final DataSourceBrowser dataSourcesPanel;
47 private final DataSourceSummaryTabbedPane dataSourceSummaryTabbedPane;
48 private final PropertyChangeListener ingestEventListener;
56 "DataSourceSummaryDialog.window.title=Data Sources Summary"
58 DataSourceSummaryDialog(Frame owner) {
59 super(owner, Bundle.DataSourceSummaryDialog_window_title(),
true);
60 Map<Long, String> usageMap = CaseDataSourcesSummary.getDataSourceTypes();
61 Map<Long, Long> fileCountsMap = CaseDataSourcesSummary.getCountsOfFiles();
62 dataSourcesPanel =
new DataSourceBrowser(usageMap, fileCountsMap);
63 dataSourceSummaryTabbedPane =
new DataSourceSummaryTabbedPane();
65 dataSourceSummarySplitPane.setLeftComponent(dataSourcesPanel);
66 dataSourcesPanel.addListSelectionListener((ListSelectionEvent e) -> {
67 if (!e.getValueIsAdjusting()) {
68 DataSource selectedDataSource = dataSourcesPanel.getSelectedDataSource();
69 dataSourceSummaryTabbedPane.setDataSource(selectedDataSource);
74 ingestEventListener = (PropertyChangeEvent evt) -> {
75 if (evt instanceof DataSourceAnalysisCompletedEvent) {
76 DataSourceAnalysisCompletedEvent dsEvent = (DataSourceAnalysisCompletedEvent) evt;
77 if (dsEvent.getResult() == Reason.ANALYSIS_COMPLETED) {
78 dataSourcesPanel.refresh(dsEvent.getDataSource().getId(), IngestJobInfo.IngestJobStatusType.COMPLETED);
79 }
else if (dsEvent.getResult() == Reason.ANALYSIS_CANCELLED) {
80 dataSourcesPanel.refresh(dsEvent.getDataSource().getId(), null);
86 IngestManager.getInstance().addIngestJobEventListener(INGEST_JOB_EVENTS_OF_INTEREST, ingestEventListener);
90 setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
95 public void dispose() {
96 IngestManager.getInstance().removeIngestJobEventListener(INGEST_JOB_EVENTS_OF_INTEREST, ingestEventListener);
97 this.dataSourceSummaryTabbedPane.close();
104 void enableObserver() {
105 dataSourcesPanel.addObserver(
this);
109 public void update(Observable o, Object arg) {
118 @SuppressWarnings(
"unchecked")
120 private
void initComponents() {
122 closeButton =
new javax.swing.JButton();
123 dataSourceSummarySplitPane =
new javax.swing.JSplitPane();
124 javax.swing.JTabbedPane dataSourceTabbedPane = dataSourceSummaryTabbedPane;
126 org.openide.awt.Mnemonics.setLocalizedText(closeButton,
org.openide.util.NbBundle.getMessage(DataSourceSummaryDialog.class,
"DataSourceSummaryDialog.closeButton.text"));
127 closeButton.addActionListener(
new java.awt.event.ActionListener() {
128 public void actionPerformed(java.awt.event.ActionEvent evt) {
129 closeButtonActionPerformed(evt);
133 dataSourceSummarySplitPane.setDividerLocation(130);
134 dataSourceSummarySplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
135 dataSourceSummarySplitPane.setRightComponent(dataSourceTabbedPane);
137 dataSourceSummarySplitPane.setLeftComponent(dataSourcesPanel);
139 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(getContentPane());
140 getContentPane().setLayout(layout);
141 layout.setHorizontalGroup(
142 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
143 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
145 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
146 .addComponent(dataSourceSummarySplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 860, Short.MAX_VALUE)
147 .addGroup(layout.createSequentialGroup()
148 .addGap(0, 0, Short.MAX_VALUE)
149 .addComponent(closeButton)))
152 layout.setVerticalGroup(
153 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
154 .addGroup(layout.createSequentialGroup()
156 .addComponent(dataSourceSummarySplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 540, Short.MAX_VALUE)
157 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
158 .addComponent(closeButton)
163 private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {
174 void selectDataSource(Long dataSourceId) {
175 dataSourcesPanel.selectDataSource(dataSourceId);
179 private javax.swing.JButton closeButton;
180 private javax.swing.JSplitPane dataSourceSummarySplitPane;