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

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