Autopsy  4.17.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
ContextUsagePanel.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 ContextUsagePanel extends javax.swing.JPanel implements ContextViewer.DateTimePanel {
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 
39  static {
40  SOURCE_CONTEXT_ARTIFACTS.add(TSK_ASSOCIATED_OBJECT);
41  }
42 
43  private final BlackboardArtifact sourceContextArtifact;
44 
45  private final Long dateTime;
46 
50  public ContextUsagePanel(String sourceName, String sourceText, BlackboardArtifact associatedArtifact, Long dateTime) {
51 
53  sourceContextArtifact = associatedArtifact;
54  setUsageName(sourceName);
55  setUsageText(sourceText);
56  this.dateTime = dateTime;
57  }
58 
59  @Override
60  public Long getDateTime() {
61  return dateTime;
62  }
63 
69  @SuppressWarnings("unchecked")
70  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
71  private void initComponents() {
72 
73  jUsageGoToResultButton = new javax.swing.JButton();
74  jUsageNameLabel = new javax.swing.JLabel();
75  jUsageTextLabel = new javax.swing.JLabel();
76 
77  setBackground(new java.awt.Color(255, 255, 255));
78  setPreferredSize(new java.awt.Dimension(495, 75));
79 
80  org.openide.awt.Mnemonics.setLocalizedText(jUsageGoToResultButton, org.openide.util.NbBundle.getMessage(ContextUsagePanel.class, "ContextUsagePanel.jUsageGoToResultButton.text")); // NOI18N
81  jUsageGoToResultButton.addActionListener(new java.awt.event.ActionListener() {
82  public void actionPerformed(java.awt.event.ActionEvent evt) {
84  }
85  });
86 
87  org.openide.awt.Mnemonics.setLocalizedText(jUsageNameLabel, org.openide.util.NbBundle.getMessage(ContextUsagePanel.class, "ContextUsagePanel.jUsageNameLabel.text")); // NOI18N
88 
89  org.openide.awt.Mnemonics.setLocalizedText(jUsageTextLabel, org.openide.util.NbBundle.getMessage(ContextUsagePanel.class, "ContextUsagePanel.jUsageTextLabel.text")); // NOI18N
90 
91  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
92  this.setLayout(layout);
93  layout.setHorizontalGroup(
94  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
95  .addGroup(layout.createSequentialGroup()
96  .addGap(50, 50, 50)
97  .addComponent(jUsageNameLabel)
98  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
99  .addComponent(jUsageTextLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 240, Short.MAX_VALUE)
100  .addGap(36, 36, 36))
101  .addGroup(layout.createSequentialGroup()
102  .addGap(90, 90, 90)
103  .addComponent(jUsageGoToResultButton)
104  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
105  );
106  layout.setVerticalGroup(
107  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
108  .addGroup(layout.createSequentialGroup()
109  .addGap(2, 2, 2)
110  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
111  .addComponent(jUsageTextLabel)
112  .addComponent(jUsageNameLabel, javax.swing.GroupLayout.Alignment.TRAILING))
113  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
114  .addComponent(jUsageGoToResultButton))
115  );
116  }// </editor-fold>//GEN-END:initComponents
117 
118  private void jUsageGoToResultButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jUsageGoToResultButtonActionPerformed
120 
121  // Navigate to the source context artifact.
122  if (sourceContextArtifact != null) {
123  dtc.viewArtifact(sourceContextArtifact);
124  }
125  }//GEN-LAST:event_jUsageGoToResultButtonActionPerformed
126 
132  private void setUsageName(String nameLabel) {
133  jUsageNameLabel.setText(nameLabel);
134  }
135 
141  private void setUsageText(String text) {
142  jUsageTextLabel.setText(text);
143  showUsageButton(!text.isEmpty());
144  showUsageText(true);
145  }
146 
147  private void showUsageText(boolean show) {
148  jUsageTextLabel.setVisible(show);
149  }
150 
151  private void showUsageButton(boolean show) {
152  jUsageGoToResultButton.setVisible(show);
153  jUsageGoToResultButton.setEnabled(show);
154  }
155 
156  // Variables declaration - do not modify//GEN-BEGIN:variables
157  private javax.swing.JButton jUsageGoToResultButton;
158  private javax.swing.JLabel jUsageNameLabel;
159  private javax.swing.JLabel jUsageTextLabel;
160  // End of variables declaration//GEN-END:variables
161 }
ContextUsagePanel(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.