30 package org.sleuthkit.autopsy.examples;
32 import java.awt.Component;
33 import org.openide.nodes.Node;
34 import org.openide.util.lookup.ServiceProvider;
48 class SampleContentViewer
extends javax.swing.JPanel implements
DataContentViewer {
53 public SampleContentViewer() {
62 @SuppressWarnings(
"unchecked")
64 private void initComponents() {
66 jLabel1 =
new javax.swing.JLabel();
68 org.openide.awt.Mnemonics.setLocalizedText(jLabel1,
org.openide.util.NbBundle.getMessage(SampleContentViewer.class,
"SampleContentViewer.jLabel1.text"));
70 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
71 this.setLayout(layout);
72 layout.setHorizontalGroup(
73 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
74 .addGroup(layout.createSequentialGroup()
76 .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 369, javax.swing.GroupLayout.PREFERRED_SIZE)
77 .addContainerGap(21, Short.MAX_VALUE))
79 layout.setVerticalGroup(
80 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
81 .addGroup(layout.createSequentialGroup()
83 .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
84 .addContainerGap(243, Short.MAX_VALUE))
88 private javax.swing.JLabel jLabel1;
92 public void setNode(Node selectedNode) {
95 if (selectedNode == null) {
101 if (content == null) {
107 setText(
"Doing Analysis");
108 byte buffer[] =
new byte[1024];
109 int len = content.
read(buffer, 0, 1024);
111 for (
int i = 0; i < len; i++) {
112 if (buffer[i] == 0x00) {
116 setText(count +
" out of " + len +
" bytes were 0x00");
118 setText(
"Error reading file: " + ex.getLocalizedMessage());
123 private void setText(String str) {
124 jLabel1.setText(str);
128 public String getTitle() {
133 public String getToolTip() {
134 return "Useless module";
139 return new SampleContentViewer();
143 public Component getComponent() {
149 public void resetComponent() {
154 public boolean isSupported(Node node) {
157 if (content == null) {
162 if (content.
getSize() < 1024) {
169 public int isPreferred(Node node) {
int read(byte[] buf, long offset, long len)