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();
64 dataSourceSummaryTabbedPane.setParentCloseListener(() -> DataSourceSummaryDialog.this.dispose());
66 dataSourceSummarySplitPane.setLeftComponent(dataSourcesPanel);
67 dataSourcesPanel.addListSelectionListener((ListSelectionEvent e) -> {
68 if (!e.getValueIsAdjusting()) {
69 DataSource selectedDataSource = dataSourcesPanel.getSelectedDataSource();
70 dataSourceSummaryTabbedPane.setDataSource(selectedDataSource);
75 ingestEventListener = (PropertyChangeEvent evt) -> {
76 if (evt instanceof DataSourceAnalysisCompletedEvent) {
77 DataSourceAnalysisCompletedEvent dsEvent = (DataSourceAnalysisCompletedEvent) evt;
78 if (dsEvent.getResult() == Reason.ANALYSIS_COMPLETED) {
79 dataSourcesPanel.refresh(dsEvent.getDataSource().getId(), IngestJobInfo.IngestJobStatusType.COMPLETED);
80 }
else if (dsEvent.getResult() == Reason.ANALYSIS_CANCELLED) {
81 dataSourcesPanel.refresh(dsEvent.getDataSource().getId(), null);
87 IngestManager.getInstance().addIngestJobEventListener(INGEST_JOB_EVENTS_OF_INTEREST, ingestEventListener);
91 setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
96 public void dispose() {
97 IngestManager.getInstance().removeIngestJobEventListener(INGEST_JOB_EVENTS_OF_INTEREST, ingestEventListener);
98 this.dataSourceSummaryTabbedPane.close();
105 void enableObserver() {
106 dataSourcesPanel.addObserver(
this);
110 public void update(Observable o, Object arg) {
119 @SuppressWarnings(
"unchecked")
121 private
void initComponents() {
123 closeButton =
new javax.swing.JButton();
124 dataSourceSummarySplitPane =
new javax.swing.JSplitPane();
125 javax.swing.JPanel dataSourceTabbedPane = dataSourceSummaryTabbedPane;
127 org.openide.awt.Mnemonics.setLocalizedText(closeButton,
org.openide.util.NbBundle.getMessage(DataSourceSummaryDialog.class,
"DataSourceSummaryDialog.closeButton.text"));
128 closeButton.addActionListener(
new java.awt.event.ActionListener() {
129 public void actionPerformed(java.awt.event.ActionEvent evt) {
130 closeButtonActionPerformed(evt);
134 dataSourceSummarySplitPane.setDividerLocation(130);
135 dataSourceSummarySplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
136 dataSourceSummarySplitPane.setRightComponent(dataSourceTabbedPane);
138 dataSourceSummarySplitPane.setLeftComponent(dataSourcesPanel);
140 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(getContentPane());
141 getContentPane().setLayout(layout);
142 layout.setHorizontalGroup(
143 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
144 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
146 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
147 .addComponent(dataSourceSummarySplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 860, Short.MAX_VALUE)
148 .addGroup(layout.createSequentialGroup()
149 .addGap(0, 0, Short.MAX_VALUE)
150 .addComponent(closeButton)))
153 layout.setVerticalGroup(
154 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
155 .addGroup(layout.createSequentialGroup()
157 .addComponent(dataSourceSummarySplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 540, Short.MAX_VALUE)
158 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
159 .addComponent(closeButton)
164 private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {
175 void selectDataSource(Long dataSourceId) {
176 dataSourcesPanel.selectDataSource(dataSourceId);
180 private javax.swing.JButton closeButton;
181 private javax.swing.JSplitPane dataSourceSummarySplitPane;