Autopsy  4.19.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
TextContentViewer.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.Messages;
24 import org.openide.util.lookup.ServiceProvider;
26 import org.sleuthkit.datamodel.AbstractFile;
27 import org.sleuthkit.datamodel.BlackboardArtifact;
28 
32 @ServiceProvider(service = DataContentViewer.class, position = 2)
33 public class TextContentViewer implements DataContentViewer {
34 
36  private volatile Node currentNode = null;
37 
41  public TextContentViewer() {
42  this(true);
43  }
44 
50  private TextContentViewer(boolean isMain) {
51  panel = new TextContentViewerPanel(isMain);
52  }
53 
54  @Override
55  public void setNode(Node selectedNode) {
56  currentNode = selectedNode;
57  panel.setNode(currentNode);
58 
59  }
60 
61  @Messages({"TextContentViewer.title=Text"})
62  @Override
63  public String getTitle() {
64  return Bundle.TextContentViewer_title();
65  }
66 
67  @Messages({"TextContentViewer.tooltip=Displays text associated with the selected item"})
68  @Override
69  public String getToolTip() {
70  return Bundle.TextContentViewer_tooltip();
71  }
72 
73  @Override
74  public DataContentViewer createInstance() {
75  return new TextContentViewer(false);
76  }
77 
78  @Override
79  public Component getComponent() {
80  return panel;
81  }
82 
83  @Override
84  public void resetComponent() {
85  currentNode = null;
86  panel.setupTabs(currentNode);
87  }
88 
89  @Override
90  public boolean isSupported(Node node) {
91  //if any of the subvewiers are supported then this is supported
92  if (node == null) {
93  return false;
94  }
95 
96  // get the node's File, if it has one
97  AbstractFile file = node.getLookup().lookup(AbstractFile.class);
98  if (file != null && (file.isDir() || file.getSize() == 0)) {
99  return false;
100  }
101 
102  return panel.isSupported(node);
103  }
104 
105  @Override
106  public int isPreferred(Node node) {
107  //return max of supported TextViewers isPreferred methods
108  return panel.isPreffered(node);
109  }
110 
111 }

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