Autopsy  4.21.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
ContextSourcePanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2020-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.contentviewers.contextviewer;
20 
21 import java.util.ArrayList;
22 import java.util.List;
26 import org.sleuthkit.datamodel.BlackboardArtifact;
27 import static org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_ASSOCIATED_OBJECT;
28 
34 public final class ContextSourcePanel extends javax.swing.JPanel implements DateTimePanel {
35 
36  private static final long serialVersionUID = 1L;
37 
38  // defines a list of artifacts that provide context for a file
39  private static final List<BlackboardArtifact.ARTIFACT_TYPE> SOURCE_CONTEXT_ARTIFACTS = new ArrayList<>();
40 
41  static {
42  SOURCE_CONTEXT_ARTIFACTS.add(TSK_ASSOCIATED_OBJECT);
43  }
44 
45  private final BlackboardArtifact sourceContextArtifact;
46 
47  private final Long dateTime;
48 
52  public ContextSourcePanel(String sourceName, String sourceText, BlackboardArtifact associatedArtifact, Long dateTime) {
53 
55  sourceContextArtifact = associatedArtifact;
56  setSourceName(sourceName);
57  setSourceText(sourceText);
58  this.dateTime = dateTime;
59  }
60 
61  @Override
62  public Long getDateTime() {
63  return dateTime;
64  }
65 
71  @SuppressWarnings("unchecked")
72  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
73  private void initComponents() {
74 
75  jSourceGoToResultButton = new javax.swing.JButton();
76  jSourceNameLabel = new javax.swing.JLabel();
77  jSourceTextLabel = new javax.swing.JLabel();
78 
80  setMaximumSize(new java.awt.Dimension(495, 55));
81  setMinimumSize(new java.awt.Dimension(300, 55));
82  setPreferredSize(new java.awt.Dimension(495, 55));
83 
84  org.openide.awt.Mnemonics.setLocalizedText(jSourceGoToResultButton, org.openide.util.NbBundle.getMessage(ContextSourcePanel.class, "ContextSourcePanel.jSourceGoToResultButton.text")); // NOI18N
85  jSourceGoToResultButton.addActionListener(new java.awt.event.ActionListener() {
86  public void actionPerformed(java.awt.event.ActionEvent evt) {
88  }
89  });
90 
91  org.openide.awt.Mnemonics.setLocalizedText(jSourceNameLabel, org.openide.util.NbBundle.getMessage(ContextSourcePanel.class, "ContextSourcePanel.jSourceNameLabel.text")); // NOI18N
92 
93  org.openide.awt.Mnemonics.setLocalizedText(jSourceTextLabel, org.openide.util.NbBundle.getMessage(ContextSourcePanel.class, "ContextSourcePanel.jSourceTextLabel.text")); // NOI18N
94 
95  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
96  this.setLayout(layout);
97  layout.setHorizontalGroup(
98  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
99  .addGroup(layout.createSequentialGroup()
100  .addComponent(jSourceNameLabel)
101  .addGap(36, 36, 36)
102  .addComponent(jSourceTextLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 360, Short.MAX_VALUE))
103  .addGroup(layout.createSequentialGroup()
104  .addGap(40, 40, 40)
105  .addComponent(jSourceGoToResultButton)
106  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
107  );
108  layout.setVerticalGroup(
109  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
110  .addGroup(layout.createSequentialGroup()
111  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
112  .addComponent(jSourceNameLabel)
113  .addComponent(jSourceTextLabel))
114  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
115  .addComponent(jSourceGoToResultButton)
116  .addGap(0, 11, Short.MAX_VALUE))
117  );
118  }// </editor-fold>//GEN-END:initComponents
119 
120  private void jSourceGoToResultButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jSourceGoToResultButtonActionPerformed
121 
123 
124  // Navigate to the source context artifact.
125  if (sourceContextArtifact != null) {
126  dtc.viewArtifact(sourceContextArtifact);
127  }
128  }//GEN-LAST:event_jSourceGoToResultButtonActionPerformed
129 
135  private void setSourceName(String nameLabel) {
136  jSourceNameLabel.setText(nameLabel);
137  }
138 
144  private void setSourceText(String text) {
145  jSourceTextLabel.setText(text);
146  showSourceButton(!text.isEmpty());
147  showSourceText(true);
148  }
149 
150  private void showSourceText(boolean show) {
151  jSourceTextLabel.setVisible(show);
152  }
153 
154  private void showSourceButton(boolean show) {
155  jSourceGoToResultButton.setVisible(show);
156  jSourceGoToResultButton.setEnabled(show);
157  }
158 
159  // Variables declaration - do not modify//GEN-BEGIN:variables
160  private javax.swing.JButton jSourceGoToResultButton;
161  private javax.swing.JLabel jSourceNameLabel;
162  private javax.swing.JLabel jSourceTextLabel;
163  // End of variables declaration//GEN-END:variables
164 }
ContextSourcePanel(String sourceName, String sourceText, BlackboardArtifact associatedArtifact, Long dateTime)
static final List< BlackboardArtifact.ARTIFACT_TYPE > SOURCE_CONTEXT_ARTIFACTS
static synchronized DirectoryTreeTopComponent findInstance()

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.