Autopsy  4.16.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  initComponents();
65  dataSourceSummarySplitPane.setLeftComponent(dataSourcesPanel);
66  dataSourcesPanel.addListSelectionListener((ListSelectionEvent e) -> {
67  if (!e.getValueIsAdjusting()) {
68  DataSource selectedDataSource = dataSourcesPanel.getSelectedDataSource();
69  dataSourceSummaryTabbedPane.setDataSource(selectedDataSource);
70  this.repaint();
71  }
72  });
73 
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);
81  }
82  }
83  };
84 
85  //add listener to refresh jobs with Started status when they complete
86  IngestManager.getInstance().addIngestJobEventListener(INGEST_JOB_EVENTS_OF_INTEREST, ingestEventListener);
87 
88  // verify that dialog will call dispose on close:
89  // https://docs.oracle.com/javase/tutorial/uiswing/components/frame.html#windowevents
90  setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
91  this.pack();
92  }
93 
94  @Override
95  public void dispose() {
96  IngestManager.getInstance().removeIngestJobEventListener(INGEST_JOB_EVENTS_OF_INTEREST, ingestEventListener);
97  this.dataSourceSummaryTabbedPane.close();
98  super.dispose();
99  }
100 
104  void enableObserver() {
105  dataSourcesPanel.addObserver(this);
106  }
107 
108  @Override
109  public void update(Observable o, Object arg) {
110  this.dispose();
111  }
112 
118  @SuppressWarnings("unchecked")
119  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
120  private void initComponents() {
121 
122  closeButton = new javax.swing.JButton();
123  dataSourceSummarySplitPane = new javax.swing.JSplitPane();
124  javax.swing.JTabbedPane dataSourceTabbedPane = dataSourceSummaryTabbedPane;
125 
126  org.openide.awt.Mnemonics.setLocalizedText(closeButton, org.openide.util.NbBundle.getMessage(DataSourceSummaryDialog.class, "DataSourceSummaryDialog.closeButton.text")); // NOI18N
127  closeButton.addActionListener(new java.awt.event.ActionListener() {
128  public void actionPerformed(java.awt.event.ActionEvent evt) {
129  closeButtonActionPerformed(evt);
130  }
131  });
132 
133  dataSourceSummarySplitPane.setDividerLocation(130);
134  dataSourceSummarySplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
135  dataSourceSummarySplitPane.setRightComponent(dataSourceTabbedPane);
136 
137  dataSourceSummarySplitPane.setLeftComponent(dataSourcesPanel);
138 
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()
144  .addContainerGap()
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)))
150  .addContainerGap())
151  );
152  layout.setVerticalGroup(
153  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
154  .addGroup(layout.createSequentialGroup()
155  .addContainerGap()
156  .addComponent(dataSourceSummarySplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 540, Short.MAX_VALUE)
157  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
158  .addComponent(closeButton)
159  .addContainerGap())
160  );
161  }// </editor-fold>//GEN-END:initComponents
162 
163  private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeButtonActionPerformed
164  this.dispose();
165  }//GEN-LAST:event_closeButtonActionPerformed
166 
174  void selectDataSource(Long dataSourceId) {
175  dataSourcesPanel.selectDataSource(dataSourceId);
176  }
177 
178  // Variables declaration - do not modify//GEN-BEGIN:variables
179  private javax.swing.JButton closeButton;
180  private javax.swing.JSplitPane dataSourceSummarySplitPane;
181  // End of variables declaration//GEN-END:variables
182 }

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.