Autopsy  4.16.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.Content;
29 
33 @ServiceProvider(service = TextViewer.class, position = 1)
34 public class StringsTextViewer implements TextViewer {
35 
37 
38  @Override
39  public void setNode(Node selectedNode) {
40  if ((selectedNode == null) || (!isSupported(selectedNode))) {
41  resetComponent();
42  return;
43  }
44  Content content = DataContentViewerUtility.getDefaultContent(selectedNode);
45  if (content != null) {
46  panel.setDataView(content, 0);
47  return;
48  } else {
49  StringContent scontent = selectedNode.getLookup().lookup(StringContent.class);
50  if (scontent != null) {
51  panel.setDataView(scontent);
52  return;
53  }
54  }
55  resetComponent();
56  }
57 
58  @Override
59  public String getTitle() {
60  return NbBundle.getMessage(this.getClass(), "StringsTextViewer.title");
61  }
62 
63  @Override
64  public String getToolTip() {
65  return NbBundle.getMessage(this.getClass(), "StringsTextViewer.toolTip");
66  }
67 
68  @Override
69  public TextViewer createInstance() {
70  return new StringsTextViewer();
71  }
72 
73  @Override
74  public void resetComponent() {
75  panel.resetDisplay();
76  }
77 
78  @Override
79  public boolean isSupported(Node node) {
80  if (node == null) {
81  return false;
82  }
83  Content content = DataContentViewerUtility.getDefaultContent(node);
84  return (content != null && content.getSize() > 0);
85  }
86 
87  @Override
88  public int isPreferred(Node node) {
89  return 1;
90  }
91 
92  @Override
93  public Component getComponent() {
94  if (panel == null) {
95  panel = new StringsContentPanel();
96  }
97  return panel;
98  }
99 
100 }

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