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

Copyright © 2012-2022 Basis Technology. Generated on: Tue Feb 6 2024
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.