Merge pull request #4850 from eugene7646/text_tab_5085

Disabled 'Text' content viewer tab for directories and empty files
This commit is contained in:
Richard Cordovano 2019-06-07 17:28:50 -04:00 committed by GitHub
commit 67619f44f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -23,6 +23,7 @@ import org.openide.nodes.Node;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
import org.openide.util.lookup.ServiceProvider; import org.openide.util.lookup.ServiceProvider;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataContentViewer; import org.sleuthkit.autopsy.corecomponentinterfaces.DataContentViewer;
import org.sleuthkit.datamodel.AbstractFile;
/** /**
* A DataContentViewer that displays text with the TextViewers available. * A DataContentViewer that displays text with the TextViewers available.
@ -90,6 +91,17 @@ public class TextContentViewer implements DataContentViewer {
if (node == null) { if (node == null) {
return false; return false;
} }
// get the node's File, if it has one
AbstractFile file = node.getLookup().lookup(AbstractFile.class);
if (file == null) {
return false;
}
// disable the text content viewer for directories and empty files
if (file.isDir() || file.getSize() == 0) {
return false;
}
return panel.isSupported(node); return panel.isSupported(node);
} }

View File

@ -79,7 +79,7 @@ public class TextContentViewerPanel extends javax.swing.JPanel implements DataCo
} }
/** /**
* Deterime wether the content viewer which displays this panel isSupported. * Determine whether the content viewer which displays this panel isSupported.
* This panel is supported if any of the TextViewer's displayed in it are * This panel is supported if any of the TextViewer's displayed in it are
* supported. * supported.
* *