Autopsy  4.17.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
DataSourceSummaryDialog.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2019 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.Frame;
22 import java.beans.PropertyChangeEvent;
23 import java.beans.PropertyChangeListener;
24 import java.util.EnumSet;
25 import java.util.Map;
26 import java.util.Observable;
27 import java.util.Observer;
28 import java.util.Set;
29 import javax.swing.WindowConstants;
30 import javax.swing.event.ListSelectionEvent;
31 import org.openide.util.NbBundle.Messages;
36 import org.sleuthkit.datamodel.DataSource;
37 import org.sleuthkit.datamodel.IngestJobInfo;
38 
42 final class DataSourceSummaryDialog extends javax.swing.JDialog implements Observer {
43 
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;
49 
55  @Messages({
56  "DataSourceSummaryDialog.window.title=Data Sources Summary"
57  })
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());
65  initComponents();
66  dataSourceSummarySplitPane.setLeftComponent(dataSourcesPanel);
67  dataSourcesPanel.addListSelectionListener((ListSelectionEvent e) -> {
68  if (!e.getValueIsAdjusting()) {
69  DataSource selectedDataSource = dataSourcesPanel.getSelectedDataSource();
70  dataSourceSummaryTabbedPane.setDataSource(selectedDataSource);
71  this.repaint();
72  }
73  });
74 
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);
82  }
83  }
84  };
85 
86  //add listener to refresh jobs with Started status when they complete
87  IngestManager.getInstance().addIngestJobEventListener(INGEST_JOB_EVENTS_OF_INTEREST, ingestEventListener);
88 
89  // verify that dialog will call dispose on close:
90  // https://docs.oracle.com/javase/tutorial/uiswing/components/frame.html#windowevents
91  setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
92  this.pack();
93  }
94 
95  @Override
96  public void dispose() {
97  IngestManager.getInstance().removeIngestJobEventListener(INGEST_JOB_EVENTS_OF_INTEREST, ingestEventListener);
98  this.dataSourceSummaryTabbedPane.close();
99  super.dispose();
100  }
101 
105  void enableObserver() {
106  dataSourcesPanel.addObserver(this);
107  }
108 
109  @Override
110  public void update(Observable o, Object arg) {
111  this.dispose();
112  }
113 
119  @SuppressWarnings("unchecked")
120  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
121  private void initComponents() {
122 
123  closeButton = new javax.swing.JButton();
124  dataSourceSummarySplitPane = new javax.swing.JSplitPane();
125  javax.swing.JPanel dataSourceTabbedPane = dataSourceSummaryTabbedPane;
126 
127  org.openide.awt.Mnemonics.setLocalizedText(closeButton, org.openide.util.NbBundle.getMessage(DataSourceSummaryDialog.class, "DataSourceSummaryDialog.closeButton.text")); // NOI18N
128  closeButton.addActionListener(new java.awt.event.ActionListener() {
129  public void actionPerformed(java.awt.event.ActionEvent evt) {
130  closeButtonActionPerformed(evt);
131  }
132  });
133 
134  dataSourceSummarySplitPane.setDividerLocation(130);
135  dataSourceSummarySplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
136  dataSourceSummarySplitPane.setRightComponent(dataSourceTabbedPane);
137 
138  dataSourceSummarySplitPane.setLeftComponent(dataSourcesPanel);
139 
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()
145  .addContainerGap()
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)))
151  .addContainerGap())
152  );
153  layout.setVerticalGroup(
154  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
155  .addGroup(layout.createSequentialGroup()
156  .addContainerGap()
157  .addComponent(dataSourceSummarySplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 540, Short.MAX_VALUE)
158  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
159  .addComponent(closeButton)
160  .addContainerGap())
161  );
162  }// </editor-fold>//GEN-END:initComponents
163 
164  private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeButtonActionPerformed
165  this.dispose();
166  }//GEN-LAST:event_closeButtonActionPerformed
167 
175  void selectDataSource(Long dataSourceId) {
176  dataSourcesPanel.selectDataSource(dataSourceId);
177  }
178 
179  // Variables declaration - do not modify//GEN-BEGIN:variables
180  private javax.swing.JButton closeButton;
181  private javax.swing.JSplitPane dataSourceSummarySplitPane;
182  // End of variables declaration//GEN-END:variables
183 }

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