Autopsy  4.14.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;
24 import org.sleuthkit.datamodel.BlackboardArtifact;
25 import static org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_ASSOCIATED_OBJECT;
26 
32 public final class ContextSourcePanel extends javax.swing.JPanel {
33 
34  private static final long serialVersionUID = 1L;
35 
36  // defines a list of artifacts that provide context for a file
37  private static final List<BlackboardArtifact.ARTIFACT_TYPE> SOURCE_CONTEXT_ARTIFACTS = new ArrayList<>();
38  static {
39  SOURCE_CONTEXT_ARTIFACTS.add(TSK_ASSOCIATED_OBJECT);
40  }
41 
42  private final BlackboardArtifact sourceContextArtifact;
43 
47  public ContextSourcePanel(String sourceName, String sourceText, BlackboardArtifact associatedArtifact) {
48 
50  sourceContextArtifact = associatedArtifact;
51  setSourceName(sourceName);
52  setSourceText(sourceText);
53  }
54 
60  @SuppressWarnings("unchecked")
61  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
62  private void initComponents() {
63 
64  jSourceGoToResultButton = new javax.swing.JButton();
65  jSourceNameLabel = new javax.swing.JLabel();
66  jSourceTextLabel = new javax.swing.JLabel();
67 
68  setBackground(new java.awt.Color(255, 255, 255));
69  setPreferredSize(new java.awt.Dimension(495, 75));
70 
71  org.openide.awt.Mnemonics.setLocalizedText(jSourceGoToResultButton, org.openide.util.NbBundle.getMessage(ContextSourcePanel.class, "ContextSourcePanel.jSourceGoToResultButton.text")); // NOI18N
72  jSourceGoToResultButton.addActionListener(new java.awt.event.ActionListener() {
73  public void actionPerformed(java.awt.event.ActionEvent evt) {
75  }
76  });
77 
78  org.openide.awt.Mnemonics.setLocalizedText(jSourceNameLabel, org.openide.util.NbBundle.getMessage(ContextSourcePanel.class, "ContextSourcePanel.jSourceNameLabel.text")); // NOI18N
79 
80  org.openide.awt.Mnemonics.setLocalizedText(jSourceTextLabel, org.openide.util.NbBundle.getMessage(ContextSourcePanel.class, "ContextSourcePanel.jSourceTextLabel.text")); // NOI18N
81 
82  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
83  this.setLayout(layout);
84  layout.setHorizontalGroup(
85  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
86  .addGroup(layout.createSequentialGroup()
87  .addGap(50, 50, 50)
88  .addComponent(jSourceNameLabel)
89  .addGap(36, 36, 36)
90  .addComponent(jSourceTextLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
91  .addGap(260, 260, 260))
92  .addGroup(layout.createSequentialGroup()
93  .addGap(90, 90, 90)
94  .addComponent(jSourceGoToResultButton)
95  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
96  );
97  layout.setVerticalGroup(
98  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
99  .addGroup(layout.createSequentialGroup()
100  .addGap(2, 2, 2)
101  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
102  .addComponent(jSourceNameLabel)
103  .addComponent(jSourceTextLabel))
104  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
105  .addComponent(jSourceGoToResultButton)
106  .addGap(0, 0, 0))
107  );
108  }// </editor-fold>//GEN-END:initComponents
109 
110  private void jSourceGoToResultButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jSourceGoToResultButtonActionPerformed
111 
113 
114  // Navigate to the source context artifact.
115  if (sourceContextArtifact != null) {
116  dtc.viewArtifact(sourceContextArtifact);
117  }
118  }//GEN-LAST:event_jSourceGoToResultButtonActionPerformed
119 
125  private void setSourceName(String nameLabel) {
126  jSourceNameLabel.setText(nameLabel);
127  }
128 
134  private void setSourceText(String text) {
135  jSourceTextLabel.setText(text);
136  showSourceButton(!text.isEmpty());
137  showSourceText(true);
138  }
139 
140  private void showSourceText(boolean show) {
141  jSourceTextLabel.setVisible(show);
142  }
143 
144  private void showSourceButton(boolean show) {
145  jSourceGoToResultButton.setVisible(show);
146  jSourceGoToResultButton.setEnabled(show);
147  }
148 
149  // Variables declaration - do not modify//GEN-BEGIN:variables
150  private javax.swing.JButton jSourceGoToResultButton;
151  private javax.swing.JLabel jSourceNameLabel;
152  private javax.swing.JLabel jSourceTextLabel;
153  // End of variables declaration//GEN-END:variables
154 }
ContextSourcePanel(String sourceName, String sourceText, BlackboardArtifact associatedArtifact)
static final List< BlackboardArtifact.ARTIFACT_TYPE > SOURCE_CONTEXT_ARTIFACTS
static synchronized DirectoryTreeTopComponent findInstance()

Copyright © 2012-2020 Basis Technology. Generated on: Wed Apr 8 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.