Autopsy  4.19.3
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-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;
25 import org.sleuthkit.datamodel.BlackboardArtifact;
26 import static org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_ASSOCIATED_OBJECT;
27 
33 public final class ContextUsagePanel extends javax.swing.JPanel implements ContextViewer.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 ContextUsagePanel(String sourceName, String sourceText, BlackboardArtifact associatedArtifact, Long dateTime) {
52 
54  sourceContextArtifact = associatedArtifact;
55  setUsageName(sourceName);
56  setUsageText(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  jUsageGoToResultButton = new javax.swing.JButton();
75  jUsageNameLabel = new javax.swing.JLabel();
76  jUsageTextLabel = new javax.swing.JLabel();
77 
79  setMaximumSize(new java.awt.Dimension(32767, 55));
80  setMinimumSize(new java.awt.Dimension(300, 55));
81  setPreferredSize(new java.awt.Dimension(495, 55));
82 
83  org.openide.awt.Mnemonics.setLocalizedText(jUsageGoToResultButton, org.openide.util.NbBundle.getMessage(ContextUsagePanel.class, "ContextUsagePanel.jUsageGoToResultButton.text")); // NOI18N
84  jUsageGoToResultButton.addActionListener(new java.awt.event.ActionListener() {
85  public void actionPerformed(java.awt.event.ActionEvent evt) {
87  }
88  });
89 
90  org.openide.awt.Mnemonics.setLocalizedText(jUsageNameLabel, org.openide.util.NbBundle.getMessage(ContextUsagePanel.class, "ContextUsagePanel.jUsageNameLabel.text")); // NOI18N
91 
92  org.openide.awt.Mnemonics.setLocalizedText(jUsageTextLabel, org.openide.util.NbBundle.getMessage(ContextUsagePanel.class, "ContextUsagePanel.jUsageTextLabel.text")); // NOI18N
93 
94  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
95  this.setLayout(layout);
96  layout.setHorizontalGroup(
97  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
98  .addGroup(layout.createSequentialGroup()
99  .addComponent(jUsageNameLabel)
100  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
101  .addComponent(jUsageTextLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 420, Short.MAX_VALUE))
102  .addGroup(layout.createSequentialGroup()
103  .addGap(40, 40, 40)
104  .addComponent(jUsageGoToResultButton)
105  .addContainerGap(275, javax.swing.GroupLayout.PREFERRED_SIZE))
106  );
107  layout.setVerticalGroup(
108  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
109  .addGroup(layout.createSequentialGroup()
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  .addGap(0, 11, Short.MAX_VALUE))
116  );
117  }// </editor-fold>//GEN-END:initComponents
118 
119  private void jUsageGoToResultButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jUsageGoToResultButtonActionPerformed
121 
122  // Navigate to the source context artifact.
123  if (sourceContextArtifact != null) {
124  dtc.viewArtifact(sourceContextArtifact);
125  }
126  }//GEN-LAST:event_jUsageGoToResultButtonActionPerformed
127 
133  private void setUsageName(String nameLabel) {
134  jUsageNameLabel.setText(nameLabel);
135  }
136 
142  private void setUsageText(String text) {
143  jUsageTextLabel.setText(text);
144  showUsageButton(!text.isEmpty());
145  showUsageText(true);
146  }
147 
148  private void showUsageText(boolean show) {
149  jUsageTextLabel.setVisible(show);
150  }
151 
152  private void showUsageButton(boolean show) {
153  jUsageGoToResultButton.setVisible(show);
154  jUsageGoToResultButton.setEnabled(show);
155  }
156 
157  // Variables declaration - do not modify//GEN-BEGIN:variables
158  private javax.swing.JButton jUsageGoToResultButton;
159  private javax.swing.JLabel jUsageNameLabel;
160  private javax.swing.JLabel jUsageTextLabel;
161  // End of variables declaration//GEN-END:variables
162 }
ContextUsagePanel(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 Jun 27 2023
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.