Autopsy  4.14.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 {
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 ContextUsagePanel(String sourceName, String sourceText, BlackboardArtifact associatedArtifact) {
48 
50  sourceContextArtifact = associatedArtifact;
51  setUsageName(sourceName);
52  setUsageText(sourceText);
53  }
54 
60  @SuppressWarnings("unchecked")
61  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
62  private void initComponents() {
63 
64  jUsageGoToResultButton = new javax.swing.JButton();
65  jUsageNameLabel = new javax.swing.JLabel();
66  jUsageTextLabel = 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(jUsageGoToResultButton, org.openide.util.NbBundle.getMessage(ContextUsagePanel.class, "ContextUsagePanel.jUsageGoToResultButton.text")); // NOI18N
72  jUsageGoToResultButton.addActionListener(new java.awt.event.ActionListener() {
73  public void actionPerformed(java.awt.event.ActionEvent evt) {
75  }
76  });
77 
78  org.openide.awt.Mnemonics.setLocalizedText(jUsageNameLabel, org.openide.util.NbBundle.getMessage(ContextUsagePanel.class, "ContextUsagePanel.jUsageNameLabel.text")); // NOI18N
79 
80  org.openide.awt.Mnemonics.setLocalizedText(jUsageTextLabel, org.openide.util.NbBundle.getMessage(ContextUsagePanel.class, "ContextUsagePanel.jUsageTextLabel.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(jUsageNameLabel)
89  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
90  .addComponent(jUsageTextLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 240, Short.MAX_VALUE)
91  .addGap(36, 36, 36))
92  .addGroup(layout.createSequentialGroup()
93  .addGap(90, 90, 90)
94  .addComponent(jUsageGoToResultButton)
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.LEADING)
102  .addComponent(jUsageTextLabel)
103  .addComponent(jUsageNameLabel, javax.swing.GroupLayout.Alignment.TRAILING))
104  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
105  .addComponent(jUsageGoToResultButton))
106  );
107  }// </editor-fold>//GEN-END:initComponents
108 
109  private void jUsageGoToResultButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jUsageGoToResultButtonActionPerformed
111 
112  // Navigate to the source context artifact.
113  if (sourceContextArtifact != null) {
114  dtc.viewArtifact(sourceContextArtifact);
115  }
116  }//GEN-LAST:event_jUsageGoToResultButtonActionPerformed
117 
123  private void setUsageName(String nameLabel) {
124  jUsageNameLabel.setText(nameLabel);
125  }
126 
132  private void setUsageText(String text) {
133  jUsageTextLabel.setText(text);
134  showUsageButton(!text.isEmpty());
135  showUsageText(true);
136  }
137 
138  private void showUsageText(boolean show) {
139  jUsageTextLabel.setVisible(show);
140  }
141 
142  private void showUsageButton(boolean show) {
143  jUsageGoToResultButton.setVisible(show);
144  jUsageGoToResultButton.setEnabled(show);
145  }
146 
147  // Variables declaration - do not modify//GEN-BEGIN:variables
148  private javax.swing.JButton jUsageGoToResultButton;
149  private javax.swing.JLabel jUsageNameLabel;
150  private javax.swing.JLabel jUsageTextLabel;
151  // End of variables declaration//GEN-END:variables
152 }
static final List< BlackboardArtifact.ARTIFACT_TYPE > SOURCE_CONTEXT_ARTIFACTS
ContextUsagePanel(String sourceName, String sourceText, BlackboardArtifact associatedArtifact)
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.