Autopsy  4.19.1
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-2021 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.Observable;
26 import java.util.Observer;
27 import java.util.Set;
28 import javax.swing.WindowConstants;
29 import javax.swing.event.ListSelectionEvent;
30 import org.openide.util.NbBundle.Messages;
34 import org.sleuthkit.datamodel.DataSource;
35 import org.sleuthkit.datamodel.IngestJobInfo;
36 
40 final class DataSourceSummaryDialog extends javax.swing.JDialog implements Observer {
41 
42  private static final long serialVersionUID = 1L;
43  private static final Set<IngestManager.IngestJobEvent> INGEST_JOB_EVENTS_OF_INTEREST = EnumSet.of(IngestManager.IngestJobEvent.DATA_SOURCE_ANALYSIS_COMPLETED);
44  private final DataSourceBrowser dataSourcesPanel;
45  private final DataSourceSummaryTabbedPane dataSourceSummaryTabbedPane;
46  private final PropertyChangeListener ingestEventListener;
47 
53  @Messages({
54  "DataSourceSummaryDialog.window.title=Data Sources Summary"
55  })
56  DataSourceSummaryDialog(Frame owner) {
57  super(owner, Bundle.DataSourceSummaryDialog_window_title(), true);
58 
59  dataSourcesPanel = new DataSourceBrowser();
60  dataSourceSummaryTabbedPane = new DataSourceSummaryTabbedPane();
61  dataSourceSummaryTabbedPane.setParentCloseListener(() -> DataSourceSummaryDialog.this.dispose());
62  initComponents();
63  dataSourceSummarySplitPane.setLeftComponent(dataSourcesPanel);
64  dataSourcesPanel.addListSelectionListener((ListSelectionEvent e) -> {
65  if (!e.getValueIsAdjusting()) {
66  DataSource selectedDataSource = dataSourcesPanel.getSelectedDataSource();
67  dataSourceSummaryTabbedPane.setDataSource(selectedDataSource);
68  this.repaint();
69  }
70  });
71 
72  ingestEventListener = (PropertyChangeEvent evt) -> {
73  if (evt instanceof DataSourceAnalysisCompletedEvent) {
74  DataSourceAnalysisCompletedEvent dsEvent = (DataSourceAnalysisCompletedEvent) evt;
75  if (dsEvent.getResult() == Reason.ANALYSIS_COMPLETED) {
76  dataSourcesPanel.refresh(dsEvent.getDataSource().getId(), IngestJobInfo.IngestJobStatusType.COMPLETED);
77  } else if (dsEvent.getResult() == Reason.ANALYSIS_CANCELLED) {
78  dataSourcesPanel.refresh(dsEvent.getDataSource().getId(), null);
79  }
80  }
81  };
82 
83  //add listener to refresh jobs with Started status when they complete
84  IngestManager.getInstance().addIngestJobEventListener(INGEST_JOB_EVENTS_OF_INTEREST, ingestEventListener);
85 
86  // verify that dialog will call dispose on close:
87  // https://docs.oracle.com/javase/tutorial/uiswing/components/frame.html#windowevents
88  setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
89  this.pack();
90  }
91 
92  @Override
93  public void dispose() {
94  IngestManager.getInstance().removeIngestJobEventListener(INGEST_JOB_EVENTS_OF_INTEREST, ingestEventListener);
95  this.dataSourceSummaryTabbedPane.close();
96  super.dispose();
97  }
98 
99  @Override
100  public void update(Observable o, Object arg) {
101  this.dispose();
102  }
103 
109  @SuppressWarnings("unchecked")
110  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
111  private void initComponents() {
112 
113  closeButton = new javax.swing.JButton();
114  dataSourceSummarySplitPane = new javax.swing.JSplitPane();
115  javax.swing.JPanel dataSourceTabbedPane = dataSourceSummaryTabbedPane;
116 
117  org.openide.awt.Mnemonics.setLocalizedText(closeButton, org.openide.util.NbBundle.getMessage(DataSourceSummaryDialog.class, "DataSourceSummaryDialog.closeButton.text")); // NOI18N
118  closeButton.addActionListener(new java.awt.event.ActionListener() {
119  public void actionPerformed(java.awt.event.ActionEvent evt) {
120  closeButtonActionPerformed(evt);
121  }
122  });
123 
124  dataSourceSummarySplitPane.setDividerLocation(130);
125  dataSourceSummarySplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
126  dataSourceSummarySplitPane.setRightComponent(dataSourceTabbedPane);
127 
128  dataSourceSummarySplitPane.setLeftComponent(dataSourcesPanel);
129 
130  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
131  getContentPane().setLayout(layout);
132  layout.setHorizontalGroup(
133  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
134  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
135  .addContainerGap()
136  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
137  .addComponent(dataSourceSummarySplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 860, Short.MAX_VALUE)
138  .addGroup(layout.createSequentialGroup()
139  .addGap(0, 0, Short.MAX_VALUE)
140  .addComponent(closeButton)))
141  .addContainerGap())
142  );
143  layout.setVerticalGroup(
144  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
145  .addGroup(layout.createSequentialGroup()
146  .addContainerGap()
147  .addComponent(dataSourceSummarySplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 540, Short.MAX_VALUE)
148  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
149  .addComponent(closeButton)
150  .addContainerGap())
151  );
152  }// </editor-fold>//GEN-END:initComponents
153 
154  private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeButtonActionPerformed
155  dataSourcesPanel.cancel();
156  this.dispose();
157  }//GEN-LAST:event_closeButtonActionPerformed
158 
159  // Variables declaration - do not modify//GEN-BEGIN:variables
160  private javax.swing.JButton closeButton;
161  private javax.swing.JSplitPane dataSourceSummarySplitPane;
162  // End of variables declaration//GEN-END:variables
163 
169  void populatePanel(Long selectedDataSource) {
170  dataSourcesPanel.populateBrowser(this, selectedDataSource);
171  }
172 }

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