Autopsy  4.17.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 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;
25 import org.sleuthkit.datamodel.BlackboardArtifact;
26 import static org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_ASSOCIATED_OBJECT;
27 
33 public final class ContextSourcePanel extends javax.swing.JPanel implements DateTimePanel {
34 
35  private static final long serialVersionUID = 1L;
36 
37  // defines a list of artifacts that provide context for a file
38  private static final List<BlackboardArtifact.ARTIFACT_TYPE> SOURCE_CONTEXT_ARTIFACTS = new ArrayList<>();
39 
40  static {
41  SOURCE_CONTEXT_ARTIFACTS.add(TSK_ASSOCIATED_OBJECT);
42  }
43 
44  private final BlackboardArtifact sourceContextArtifact;
45 
46  private final Long dateTime;
47 
51  public ContextSourcePanel(String sourceName, String sourceText, BlackboardArtifact associatedArtifact, Long dateTime) {
52 
54  sourceContextArtifact = associatedArtifact;
55  setSourceName(sourceName);
56  setSourceText(sourceText);
57  this.dateTime = dateTime;
58  }
59 
60  @Override
61  public Long getDateTime() {
62  return dateTime;
63  }
64 
70  @SuppressWarnings("unchecked")
71  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
72  private void initComponents() {
73 
74  jSourceGoToResultButton = new javax.swing.JButton();
75  jSourceNameLabel = new javax.swing.JLabel();
76  jSourceTextLabel = new javax.swing.JLabel();
77 
78  setBackground(new java.awt.Color(255, 255, 255));
79  setPreferredSize(new java.awt.Dimension(495, 75));
80 
81  org.openide.awt.Mnemonics.setLocalizedText(jSourceGoToResultButton, org.openide.util.NbBundle.getMessage(ContextSourcePanel.class, "ContextSourcePanel.jSourceGoToResultButton.text")); // NOI18N
82  jSourceGoToResultButton.addActionListener(new java.awt.event.ActionListener() {
83  public void actionPerformed(java.awt.event.ActionEvent evt) {
85  }
86  });
87 
88  org.openide.awt.Mnemonics.setLocalizedText(jSourceNameLabel, org.openide.util.NbBundle.getMessage(ContextSourcePanel.class, "ContextSourcePanel.jSourceNameLabel.text")); // NOI18N
89 
90  org.openide.awt.Mnemonics.setLocalizedText(jSourceTextLabel, org.openide.util.NbBundle.getMessage(ContextSourcePanel.class, "ContextSourcePanel.jSourceTextLabel.text")); // NOI18N
91 
92  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
93  this.setLayout(layout);
94  layout.setHorizontalGroup(
95  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
96  .addGroup(layout.createSequentialGroup()
97  .addGap(50, 50, 50)
98  .addComponent(jSourceNameLabel)
99  .addGap(36, 36, 36)
100  .addComponent(jSourceTextLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
101  .addGap(260, 260, 260))
102  .addGroup(layout.createSequentialGroup()
103  .addGap(90, 90, 90)
104  .addComponent(jSourceGoToResultButton)
105  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
106  );
107  layout.setVerticalGroup(
108  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
109  .addGroup(layout.createSequentialGroup()
110  .addGap(2, 2, 2)
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, 0, 0))
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-2021 Basis Technology. Generated on: Tue Jan 19 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.