Autopsy  4.19.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
StringsTextViewer.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2019 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.textcontentviewer;
20 
21 import java.awt.Component;
22 import org.openide.nodes.Node;
23 import org.openide.util.NbBundle;
24 import org.openide.util.lookup.ServiceProvider;
28 import org.sleuthkit.datamodel.BlackboardArtifact;
29 import org.sleuthkit.datamodel.Content;
30 
34 @ServiceProvider(service = TextViewer.class, position = 1)
35 public class StringsTextViewer implements TextViewer {
36 
38 
39  @Override
40  public void setNode(Node selectedNode) {
41  if ((selectedNode == null) || (!isSupported(selectedNode))) {
42  resetComponent();
43  return;
44  }
45  Content content = DataContentViewerUtility.getDefaultContent(selectedNode);
46  if (content != null) {
47  panel.setDataView(content, 0);
48  return;
49  } else {
50  StringContent scontent = selectedNode.getLookup().lookup(StringContent.class);
51  if (scontent != null) {
52  panel.setDataView(scontent);
53  return;
54  }
55  }
56  resetComponent();
57  }
58 
59  @Override
60  public String getTitle() {
61  return NbBundle.getMessage(this.getClass(), "StringsTextViewer.title");
62  }
63 
64  @Override
65  public String getToolTip() {
66  return NbBundle.getMessage(this.getClass(), "StringsTextViewer.toolTip");
67  }
68 
69  @Override
70  public TextViewer createInstance() {
71  return new StringsTextViewer();
72  }
73 
74  @Override
75  public void resetComponent() {
76  panel.resetDisplay();
77  }
78 
79  @Override
80  public boolean isSupported(Node node) {
81  if (node == null) {
82  return false;
83  }
84  Content content = DataContentViewerUtility.getDefaultContent(node);
85  return (content != null && !(content instanceof BlackboardArtifact) && content.getSize() > 0);
86  }
87 
88  @Override
89  public int isPreferred(Node node) {
90  return 1;
91  }
92 
93  @Override
94  public Component getComponent() {
95  if (panel == null) {
96  panel = new StringsContentPanel();
97  }
98  return panel;
99  }
100 
101 }

Copyright © 2012-2021 Basis Technology. Generated on: Fri Aug 6 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.