Autopsy  4.21.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
DataSourceSummaryResultViewer.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2020 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.resultviewers.summary;
20 
21 import java.awt.BorderLayout;
22 import java.awt.Cursor;
23 import java.util.logging.Level;
24 import javax.swing.SwingUtilities;
25 import org.openide.explorer.ExplorerManager;
26 import org.openide.nodes.Node;
27 import org.openide.util.NbBundle.Messages;
28 import org.openide.util.lookup.ServiceProvider;
32 import org.sleuthkit.datamodel.DataSource;
35 
39 @ServiceProvider(service = DataResultViewer.class)
40 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
42 
43  private static final long serialVersionUID = 1L;
44  private static final Logger LOGGER = Logger.getLogger(DataSourceSummaryResultViewer.class.getName());
45 
46  private final String title;
47 
53  this(null);
54  }
55 
64  @Messages({
65  "DataSourceSummaryResultViewer_title=Summary"
66  })
67  public DataSourceSummaryResultViewer(ExplorerManager explorerManager) {
68  this(explorerManager, Bundle.DataSourceSummaryResultViewer_title());
69  }
70 
80  public DataSourceSummaryResultViewer(ExplorerManager explorerManager, String title) {
81  super(explorerManager);
82  this.title = title;
83  initComponents();
84  }
85 
86  @Override
88  return new DataSourceSummaryResultViewer();
89  }
90 
91  @Override
92  public boolean isSupported(Node node) {
93  return getDataSource(node) != null;
94  }
95 
103  private DataSource getDataSource(Node node) {
104  return node == null ? null : node.getLookup().lookup(DataSource.class);
105  }
106 
107  @Override
109  public void setNode(Node node) {
110  if (!SwingUtilities.isEventDispatchThread()) {
111  LOGGER.log(Level.SEVERE, "Attempting to run setNode() from non-EDT thread.");
112  return;
113  }
114 
115  DataSource dataSource = getDataSource(node);
116 
117  this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
118  try {
119  if (summaryPanel != null) {
120  summaryPanel.setDataSource(dataSource);
121  }
122  } finally {
123  this.setCursor(null);
124  }
125  }
126 
127  @Override
128  public String getTitle() {
129  return title;
130  }
131 
132  private void initComponents() {
133  summaryPanel = new DataSourceSummaryTabbedPane();
134  setLayout(new BorderLayout());
135  add(summaryPanel, BorderLayout.CENTER);
136  }
137 
138  @Override
139  public void clearComponent() {
140  summaryPanel.close();
141  summaryPanel = null;
142  }
143 
145 
146 }
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2022 Basis Technology. Generated on: Tue Feb 6 2024
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.