19 package org.sleuthkit.autopsy.discovery.ui;
21 import com.google.common.eventbus.Subscribe;
22 import java.awt.Component;
23 import javax.swing.JPanel;
24 import javax.swing.SwingUtilities;
25 import javax.swing.event.ChangeEvent;
26 import javax.swing.event.ChangeListener;
27 import org.apache.commons.lang.StringUtils;
28 import org.openide.util.NbBundle;
38 final class DomainDetailsPanel
extends JPanel {
40 private static final long serialVersionUID = 1L;
41 private ArtifactsWorker singleArtifactDomainWorker;
42 private String domain;
43 private String selectedTabName = null;
50 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
51 DomainDetailsPanel() {
53 MiniTimelinePanel timelinePanel =
new MiniTimelinePanel();
54 DiscoveryEventUtils.getDiscoveryEventBus().register(timelinePanel);
55 jTabbedPane1.add(Bundle.DomainDetailsPanel_miniTimelineTitle_text(), timelinePanel);
56 for (BlackboardArtifact.ARTIFACT_TYPE type : SearchData.Type.DOMAIN.getArtifactTypes()) {
57 jTabbedPane1.add(type.getDisplayName(),
new DomainArtifactsTabPanel(type));
67 @NbBundle.Messages({
"DomainDetailsPanel.miniTimelineTitle.text=Timeline"})
68 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
69 void configureArtifactTabs(String tabName) {
70 selectedTabName = tabName;
71 if (StringUtils.isBlank(selectedTabName)) {
72 selectedTabName = Bundle.DomainDetailsPanel_miniTimelineTitle_text();
75 jTabbedPane1.addChangeListener(
new ChangeListener() {
77 public void stateChanged(ChangeEvent e) {
78 if (jTabbedPane1.getSelectedIndex() >= 0) {
79 String newTabTitle = jTabbedPane1.getTitleAt(jTabbedPane1.getSelectedIndex());
80 if (selectedTabName == null || !selectedTabName.equals(newTabTitle)) {
81 selectedTabName = newTabTitle;
82 Component selectedComponent = jTabbedPane1.getSelectedComponent();
83 if (selectedComponent instanceof DomainArtifactsTabPanel) {
84 runDomainWorker((DomainArtifactsTabPanel) selectedComponent);
85 }
else if (selectedComponent instanceof MiniTimelinePanel) {
86 runMiniTimelineWorker((MiniTimelinePanel) selectedComponent);
94 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
99 private
void selectTab() {
100 for (
int i = 0; i < jTabbedPane1.getTabCount(); i++) {
101 if (!StringUtils.isBlank(selectedTabName) && selectedTabName.equals(jTabbedPane1.getTitleAt(i))) {
102 jTabbedPane1.setSelectedIndex(i);
113 DomainArtifactsTabPanel.ArtifactRetrievalStatus getCurrentTabStatus() {
114 if (jTabbedPane1.getSelectedComponent() instanceof MiniTimelinePanel) {
115 return ((MiniTimelinePanel) jTabbedPane1.getSelectedComponent()).getStatus();
116 }
else if (jTabbedPane1.getSelectedComponent() instanceof DomainArtifactsTabPanel) {
117 return ((DomainArtifactsTabPanel) jTabbedPane1.getSelectedComponent()).getStatus();
126 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
127 private
void runDomainWorker(DomainArtifactsTabPanel domainArtifactsTabPanel) {
128 if (singleArtifactDomainWorker != null && !singleArtifactDomainWorker.isDone()) {
129 singleArtifactDomainWorker.cancel(
true);
131 if (domainArtifactsTabPanel.getStatus() == DomainArtifactsTabPanel.ArtifactRetrievalStatus.UNPOPULATED) {
132 DiscoveryEventUtils.getDiscoveryEventBus().register(domainArtifactsTabPanel);
133 domainArtifactsTabPanel.setStatus(DomainArtifactsTabPanel.ArtifactRetrievalStatus.POPULATING);
134 singleArtifactDomainWorker =
new ArtifactsWorker(domainArtifactsTabPanel.getArtifactType(), domain);
135 singleArtifactDomainWorker.execute();
144 private void runMiniTimelineWorker(MiniTimelinePanel miniTimelinePanel) {
145 if (miniTimelinePanel.getStatus() == DomainArtifactsTabPanel.ArtifactRetrievalStatus.UNPOPULATED) {
146 miniTimelinePanel.setStatus(DomainArtifactsTabPanel.ArtifactRetrievalStatus.POPULATING, domain);
147 new MiniTimelineWorker(domain).execute();
158 void handlePopulateDomainTabsEvent(DiscoveryEventUtils.PopulateDomainTabsEvent populateEvent) {
159 SwingUtilities.invokeLater(() -> {
160 if (StringUtils.isBlank(populateEvent.getDomain())) {
163 DiscoveryEventUtils.getDiscoveryEventBus().post(
new DiscoveryEventUtils.DetailsVisibleEvent(
false));
165 domain = populateEvent.getDomain();
166 Component selectedComponent = jTabbedPane1.getSelectedComponent();
167 if (selectedComponent instanceof DomainArtifactsTabPanel) {
168 runDomainWorker((DomainArtifactsTabPanel) selectedComponent);
169 }
else if (selectedComponent instanceof MiniTimelinePanel) {
170 runMiniTimelineWorker((MiniTimelinePanel) selectedComponent);
173 DiscoveryEventUtils.getDiscoveryEventBus().post(
new DiscoveryEventUtils.DetailsVisibleEvent(
true));
182 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
183 private
void resetTabsStatus() {
184 for (Component comp : jTabbedPane1.getComponents()) {
185 if (comp instanceof DomainArtifactsTabPanel) {
186 ((DomainArtifactsTabPanel) comp).setStatus(DomainArtifactsTabPanel.ArtifactRetrievalStatus.UNPOPULATED);
187 }
else if (comp instanceof MiniTimelinePanel) {
188 ((MiniTimelinePanel) comp).setStatus(DomainArtifactsTabPanel.ArtifactRetrievalStatus.UNPOPULATED, domain);
198 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
199 String getSelectedTabName() {
200 return selectedTabName;
208 @SuppressWarnings(
"unchecked")
210 private
void initComponents() {
212 jTabbedPane1 =
new javax.swing.JTabbedPane();
215 setMinimumSize(
new java.awt.Dimension(0, 0));
216 setPreferredSize(
new java.awt.Dimension(0, 0));
217 setLayout(
new java.awt.BorderLayout());
219 jTabbedPane1.setMinimumSize(
new java.awt.Dimension(0, 0));
220 jTabbedPane1.setPreferredSize(
new java.awt.Dimension(0, 0));
221 add(jTabbedPane1, java.awt.BorderLayout.CENTER);
225 private javax.swing.JTabbedPane jTabbedPane1;
232 for (Component comp : jTabbedPane1.getComponents()) {
233 if (comp instanceof MiniTimelinePanel) {
234 DiscoveryEventUtils.getDiscoveryEventBus().unregister(comp);