Merge branch 'new-features-20120503' of https://github.com/sleuthkit/autopsy into new-features-20120503

This commit is contained in:
adam-m 2012-06-20 17:04:00 -04:00
commit f29b106967
15 changed files with 126 additions and 89 deletions

View File

@ -74,8 +74,11 @@ public interface DataContentViewer {
* @param node Node to check for preference
* @param isSupported, true if the viewer is supported by the node
* as determined by a previous check
* @return True if viewer preferred, else false
* @return an int (0-10) higher return means the viewer has higher priority
* 0 means not supported
* 1/2 means will display all supported
* 3-10 are prioritized by Content viewer developer
*/
public boolean isPreferred(Node node, boolean isSupported);
public int isPreferred(Node node, boolean isSupported);
}

View File

@ -98,7 +98,7 @@ public final class DataContentTopComponent extends TopComponent implements DataC
return this.wrapped.isSupported(node);
}
boolean isPreferred(Node node, boolean isSupported) {
int isPreferred(Node node, boolean isSupported) {
return this.wrapped.isPreferred(node, isSupported);
}
}
@ -293,17 +293,10 @@ public final class DataContentTopComponent extends TopComponent implements DataC
int totalTabs = dataContentTabbedPane.getTabCount();
List<DataContentViewer> dcvs = new ArrayList<DataContentViewer>();
dcvs.addAll(Lookup.getDefault().lookupAll(DataContentViewer.class));
for (int i = 0; i<dcvs.size(); i++){
DataContentViewer dcv = dcvs.get(i);
if(dcv.getTitle().equals("String View") && dataContentTabbedPane.getTabCount() > i){
dataContentTabbedPane.setSelectedIndex(i);
}
}
int maxPreferred = 0;
int indexOfPreferred = 0;
if (totalTabs > 0) { // make sure there are tabs to reset
int tempIndex = dataContentTabbedPane.getSelectedIndex();
for (int i = 0; i < totalTabs; i++) {
UpdateWrapper dcv = viewers.get(i);
dcv.resetComponent();
@ -312,25 +305,19 @@ public final class DataContentTopComponent extends TopComponent implements DataC
boolean dcvSupported = dcv.isSupported(selectedNode);
if (! dcvSupported) {
dataContentTabbedPane.setEnabledAt(i, false);
// change the tab selection if it's the current selection
if (tempIndex == i) {
if (i > 0) {
dataContentTabbedPane.setSelectedIndex(0);
} else {
dataContentTabbedPane.setSelectedIndex(1);
}
}
} else {
dataContentTabbedPane.setEnabledAt(i, true);
if (dcv.isPreferred(selectedNode, dcvSupported))
dataContentTabbedPane.setSelectedIndex(i);
int currentPreferred = dcv.isPreferred(selectedNode, dcvSupported);
if (currentPreferred > maxPreferred) {
indexOfPreferred = i;
maxPreferred = currentPreferred;
}
}
}
int newIndex = dataContentTabbedPane.getSelectedIndex();
// set the display of the tab
viewers.get(newIndex).setNode(selectedNode);
dataContentTabbedPane.setSelectedIndex(indexOfPreferred);
viewers.get(indexOfPreferred).setNode(selectedNode);
}
}

View File

@ -46,7 +46,7 @@ import org.sleuthkit.datamodel.TskException;
/**
* Viewer displays Artifacts associated with Contents
*/
@ServiceProvider(service = DataContentViewer.class)
@ServiceProvider(service = DataContentViewer.class, position=3)
public class DataContentViewerArtifact extends javax.swing.JPanel implements DataContentViewer{
private static int currentPage = 1;
@ -314,12 +314,17 @@ public class DataContentViewerArtifact extends javax.swing.JPanel implements Dat
}
@Override
public boolean isPreferred(Node node, boolean isSupported) {
public int isPreferred(Node node, boolean isSupported) {
BlackboardArtifact art = node.getLookup().lookup(BlackboardArtifact.class);
if(art != null && art.getArtifactTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID())
return true;
else
return false;
if(isSupported) {
if(art == null) {
return 3;
} else {
return 5;
}
} else {
return 0;
}
}
private void customizeComponents(){

View File

@ -39,7 +39,7 @@ import org.sleuthkit.datamodel.TskException;
/**
* Hex view of file contents.
*/
@ServiceProvider(service = DataContentViewer.class)
@ServiceProvider(service = DataContentViewer.class, position=1)
public class DataContentViewerHex extends javax.swing.JPanel implements DataContentViewer {
private static long currentOffset = 0;
@ -257,7 +257,7 @@ public class DataContentViewerHex extends javax.swing.JPanel implements DataCont
private void goToPageTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_goToPageTextFieldActionPerformed
String pageNumberStr = goToPageTextField.getText();
int pageNumber = 0;
int maxPage = (int) (dataSource.getSize() / pageLength) + 1;
int maxPage = Math.round(dataSource.getSize() / pageLength);
try {
pageNumber = Integer.parseInt(pageNumberStr);
} catch (NumberFormatException ex) {
@ -333,7 +333,7 @@ public class DataContentViewerHex extends javax.swing.JPanel implements DataCont
}
if (setVisible) {
int totalPage = (int) (dataSource.getSize() / pageLength) + 1;
int totalPage = Math.round(dataSource.getSize() / pageLength);
totalPageLabel.setText(Integer.toString(totalPage));
currentPageLabel.setText(Integer.toString(currentPage));
setComponentsVisibility(true); // shows the components that not needed
@ -361,6 +361,10 @@ public class DataContentViewerHex extends javax.swing.JPanel implements DataCont
@Override
public void setNode(Node selectedNode) {
if(!isSupported(selectedNode)) {
setDataView(null, 0, true);
return;
}
if (selectedNode != null) {
Content content = (selectedNode).getLookup().lookup(Content.class);
if (content != null) {
@ -413,6 +417,8 @@ public class DataContentViewerHex extends javax.swing.JPanel implements DataCont
nextPageButton.setVisible(isVisible);
pageLabel.setVisible(isVisible);
pageLabel2.setVisible(isVisible);
goToPageTextField.setVisible(isVisible);
goToPageLabel.setVisible(isVisible);
}
@Override
@ -430,8 +436,12 @@ public class DataContentViewerHex extends javax.swing.JPanel implements DataCont
}
@Override
public boolean isPreferred(Node node, boolean isSupported) {
return false;
public int isPreferred(Node node, boolean isSupported) {
if(isSupported) {
return 1;
} else {
return 0;
}
}
@Override

View File

@ -45,7 +45,7 @@ import org.sleuthkit.datamodel.TskData;
*
* @author dfickling
*/
@ServiceProvider(service = DataContentViewer.class)
@ServiceProvider(service = DataContentViewer.class, position=5)
public class DataContentViewerMedia extends javax.swing.JPanel implements DataContentViewer {
private static final String[] IMAGES = new String[]{ ".jpg", ".jpeg", ".png", ".gif", ".jpe", ".bmp"};
@ -172,6 +172,9 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
}
File file = selectedNode.getLookup().lookup(File.class);
setDataView(file);
if(file == null) {
return;
}
boolean isVidOrAud = containsExt(file.getName(), VIDEOS) || containsExt(file.getName(), AUDIOS);
pauseButton.setVisible(isVidOrAud);
progressLabel.setVisible(isVidOrAud);
@ -179,8 +182,12 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
}
private void setDataView(File file) {
if(file == null)
if(file == null) {
setComponentsVisibility(false);
return;
} else {
setComponentsVisibility(true);
}
this.currentFile = file;
if (containsExt(file.getName(), IMAGES)) {
@ -196,6 +203,17 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
playbin2.play();
}
}
/**
* To set the visibility of specific components in this class.
*
* @param isVisible whether to show or hide the specific components
*/
private void setComponentsVisibility(boolean isVisible) {
pauseButton.setVisible(isVisible);
progressLabel.setVisible(isVisible);
progressSlider.setVisible(isVisible);
videoPanel.setVisible(isVisible);
}
@Override
public String getTitle() {
@ -283,8 +301,12 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
}
@Override
public boolean isPreferred(Node node, boolean isSupported) {
return isSupported;
public int isPreferred(Node node, boolean isSupported) {
if(isSupported) {
return 7;
} else {
return 0;
}
}
private static boolean containsExt(String name, String[] exts) {

View File

@ -178,8 +178,12 @@ public class DataContentViewerPicture extends javax.swing.JPanel implements Data
}
@Override
public boolean isPreferred(Node node, boolean isSupported) {
return isSupported;
public int isPreferred(Node node, boolean isSupported) {
if(isSupported) {
return 1;
} else {
return 0;
}
}
@Override

View File

@ -40,7 +40,7 @@ import org.sleuthkit.datamodel.TskException;
/**
* Viewer displays strings extracted from contents.
*/
@ServiceProvider(service = DataContentViewer.class)
@ServiceProvider(service = DataContentViewer.class, position=2)
public class DataContentViewerString extends javax.swing.JPanel implements DataContentViewer {
private static long currentOffset = 0;
@ -241,7 +241,7 @@ public class DataContentViewerString extends javax.swing.JPanel implements DataC
private void goToPageTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_goToPageTextFieldActionPerformed
String pageNumberStr = goToPageTextField.getText();
int pageNumber = 0;
int maxPage = (int) (dataSource.getSize() / pageLength) + 1;
int maxPage = Math.round(dataSource.getSize() / pageLength);
try {
pageNumber = Integer.parseInt(pageNumberStr);
} catch (NumberFormatException ex) {
@ -320,7 +320,7 @@ public class DataContentViewerString extends javax.swing.JPanel implements DataC
}
if (setVisible) {
int totalPage = (int) (dataSource.getSize() / pageLength) + 1;
int totalPage = Math.round(dataSource.getSize() / pageLength);
totalPageLabel.setText(Integer.toString(totalPage));
currentPageLabel.setText(Integer.toString(currentPage));
outputViewPane.setText(text); // set the output view
@ -355,10 +355,16 @@ public class DataContentViewerString extends javax.swing.JPanel implements DataC
nextPageButton.setVisible(isVisible);
pageLabel.setVisible(isVisible);
pageLabel2.setVisible(isVisible);
goToPageTextField.setVisible(isVisible);
goToPageLabel.setVisible(isVisible);
}
@Override
public void setNode(Node selectedNode) {
if(!isSupported(selectedNode)) {
setDataView(null, 0, true);
return;
}
if (selectedNode != null) {
Lookup lookup = selectedNode.getLookup();
Content content = lookup.lookup(Content.class);
@ -421,14 +427,12 @@ public class DataContentViewerString extends javax.swing.JPanel implements DataC
}
@Override
public boolean isPreferred(Node node, boolean isSupported) {
public int isPreferred(Node node, boolean isSupported) {
if(node != null && isSupported){
StringContent scontent = node.getLookup().lookup(StringContent.class);
if(scontent != null){
return true;
}
return 2;
} else {
return 0;
}
return false;
}
@Override

View File

@ -186,6 +186,7 @@ public abstract class AbstractFsContentNode<T extends FsContent> extends Abstrac
// selecting a file filter (e.g. 'type' or 'recent'), it is false
AbstractFsContentNode(T fsContent, boolean directoryBrowseMode) {
super(fsContent);
this.setDisplayName(AbstractFsContentNode.getFsContentName(fsContent));
this.directoryBrowseMode = directoryBrowseMode;
}
@ -226,7 +227,7 @@ public abstract class AbstractFsContentNode<T extends FsContent> extends Abstrac
* @param content to extract properties from
*/
public static void fillPropertyMap(Map<String, Object> map, FsContent content) {
map.put(FsContentPropertyType.NAME.toString(), content.getName());
map.put(FsContentPropertyType.NAME.toString(), getFsContentName(content));
map.put(FsContentPropertyType.LOCATION.toString(), DataConversion.getformattedPath(ContentUtils.getDisplayPath(content), 0, 1));
map.put(FsContentPropertyType.MOD_TIME.toString(), ContentUtils.getStringTime(content.getMtime(), content));
map.put(FsContentPropertyType.CHANGED_TIME.toString(), ContentUtils.getStringTime(content.getCtime(), content));
@ -245,4 +246,14 @@ public abstract class AbstractFsContentNode<T extends FsContent> extends Abstrac
map.put(FsContentPropertyType.KNOWN.toString(), content.getKnown().getName());
map.put(FsContentPropertyType.MD5HASH.toString(), content.getMd5Hash() == null ? "" : content.getMd5Hash());
}
static String getFsContentName(FsContent fsContent) {
String name = fsContent.getName();
if(name.equals("..")) {
name = DirectoryNode.DOTDOTDIR;
} else if(name.equals(".")) {
name = DirectoryNode.DOTDIR;
}
return name;
}
}

View File

@ -28,15 +28,8 @@ import org.sleuthkit.datamodel.TskData;
*/
public class DirectoryNode extends AbstractFsContentNode<Directory> {
/**
* Helper so that the display name and the name used in building the path
* are determined the same way.
* @param d Directory to get the name of
* @return short name for the directory
*/
static String nameForDirectory(Directory d) {
return d.getName();
}
public static final String DOTDOTDIR = "[parent folder]";
public static final String DOTDIR = "[current folder]";
public DirectoryNode(Directory dir) {
this(dir, true);
@ -50,8 +43,6 @@ public class DirectoryNode extends AbstractFsContentNode<Directory> {
super(dir, directoryBrowseMode);
// set name, display name, and icon
String dirName = nameForDirectory(dir);
this.setDisplayName(dirName);
if (Directory.dirFlagToValue(dir.getDir_flags()).equals(TskData.TSK_FS_NAME_FLAG_ENUM.TSK_FS_NAME_FLAG_UNALLOC.toString())) {
this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/folder-icon-deleted.png");
} else {

View File

@ -30,16 +30,6 @@ import org.sleuthkit.datamodel.TskData;
*/
public class FileNode extends AbstractFsContentNode<File> {
/**
* Helper so that the display name and the name used in building the path
* are determined the same way.
* @param f File to get the name of
* @return short name for the File
*/
static String nameForFile(File f) {
return f.getName();
}
/**
*
* @param file underlying Content
@ -52,8 +42,6 @@ public class FileNode extends AbstractFsContentNode<File> {
super(file, directoryBrowseMode);
// set name, display name, and icon
String fileName = nameForFile(file);
this.setDisplayName(fileName);
if (File.dirFlagToValue(file.getDir_flags()).equals(TskData.TSK_FS_NAME_FLAG_ENUM.TSK_FS_NAME_FLAG_UNALLOC.toString())) {
this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/file-icon-deleted.png");
} else {

View File

@ -30,7 +30,7 @@ import org.sleuthkit.autopsy.coreutils.Log;
*
* @author jantonius
*/
public class CollapseAction extends AbstractAction {
class CollapseAction extends AbstractAction {
CollapseAction(String title) {
super(title);

View File

@ -46,6 +46,7 @@ import org.sleuthkit.autopsy.datamodel.ExtractedContentNode;
import org.sleuthkit.autopsy.datamodel.FileNode;
import org.sleuthkit.autopsy.datamodel.FileSearchFilterNode;
import org.sleuthkit.autopsy.datamodel.HashsetHits.HashsetHitsRootNode;
import org.sleuthkit.autopsy.datamodel.HashsetHits.HashsetHitsSetNode;
import org.sleuthkit.autopsy.datamodel.ImageNode;
import org.sleuthkit.autopsy.datamodel.KeywordHits.KeywordHitsKeywordNode;
import org.sleuthkit.autopsy.datamodel.KeywordHits.KeywordHitsListNode;
@ -154,7 +155,6 @@ public class DataResultFilterNode extends FilterNode{
List<Action> actions = new ArrayList<Action>();
actions.add(new NewWindowViewAction("View in New Window", vol));
actions.addAll(ShowDetailActionVisitor.getActions(vol.getLookup().lookup(Content.class)));
actions.add(new ChangeViewAction("View", 0, vol));
return actions;
}
@ -271,6 +271,11 @@ public class DataResultFilterNode extends FilterNode{
return openChild(hhrn);
}
@Override
public AbstractAction visit(HashsetHitsSetNode hhsn) {
return openChild(hhsn);
}
@Override
public AbstractAction visit(EmailExtractedRootNode eern) {
return openChild(eern);
@ -303,9 +308,9 @@ public class DataResultFilterNode extends FilterNode{
@Override
public AbstractAction visit(DirectoryNode dn){
if(dn.getDisplayName().equals(".."))
if(dn.getDisplayName().equals(DirectoryNode.DOTDOTDIR))
return openParent(dn);
else if(!dn.getDisplayName().equals("."))
else if(!dn.getDisplayName().equals(DirectoryNode.DOTDIR))
return openChild(dn);
else
return null;

View File

@ -89,11 +89,10 @@ class DirectoryTreeFilterChildren extends FilterNode.Children {
|| arg0 instanceof HashsetHitsRootNode
|| arg0 instanceof EmailExtractedRootNode
|| arg0 instanceof EmailExtractedAccountNode
|| arg0 instanceof EmailExtractedFolderNode
|| arg0 instanceof ImagesNode
|| arg0 instanceof ViewsNode
|| arg0 instanceof ResultsNode)) {
return new Node[]{this.copyNode(arg0)};
return new Node[]{this.copyNode(arg0, true)};
} else if (arg0 != null
&& (arg0 instanceof KeywordHitsKeywordNode
|| (arg0 instanceof DirectoryNode
@ -102,8 +101,6 @@ class DirectoryTreeFilterChildren extends FilterNode.Children {
|| arg0 instanceof RecentFilesFilterNode
|| arg0 instanceof FileSearchFilterNode
|| arg0 instanceof HashsetHitsSetNode
|| arg0 instanceof EmailExtractedRootNode
|| arg0 instanceof EmailExtractedAccountNode
|| arg0 instanceof EmailExtractedFolderNode
)) {
return new Node[]{this.copyNode(arg0, false)};
@ -142,7 +139,7 @@ class DirectoryTreeFilterChildren extends FilterNode.Children {
*/
private static boolean isDotDirectory(DirectoryNode dir) {
String name = dir.getDisplayName();
return name.equals(".") || name.equals("..");
return name.equals(DirectoryNode.DOTDIR) || name.equals(DirectoryNode.DOTDOTDIR);
}
/**

View File

@ -63,7 +63,6 @@ class DirectoryTreeFilterNode extends FilterNode {
Content c = this.getLookup().lookup(Content.class);
if (c != null) {
actions.addAll(DirectoryTreeFilterNode.getDetailActions(c));
actions.add(collapseAll);
Directory dir = this.getLookup().lookup(Directory.class);
if (dir != null) {
@ -83,6 +82,7 @@ class DirectoryTreeFilterNode extends FilterNode {
});
}
}
actions.add(collapseAll);
return actions.toArray(new Action[actions.size()]);
}

View File

@ -45,7 +45,7 @@ import org.sleuthkit.datamodel.Directory;
* MarkupSource items in the selected Node's lookup, plus the content that
* Solr extracted (if there is any).
*/
@ServiceProvider(service = DataContentViewer.class)
@ServiceProvider(service = DataContentViewer.class, position=4)
public class ExtractedContentViewer implements DataContentViewer {
private static final Logger logger = Logger.getLogger(ExtractedContentViewer.class.getName());
@ -304,10 +304,20 @@ public class ExtractedContentViewer implements DataContentViewer {
}
@Override
public boolean isPreferred(Node node,
public int isPreferred(Node node,
boolean isSupported) {
BlackboardArtifact art = node.getLookup().lookup(BlackboardArtifact.class);
return isSupported && (art == null || art.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID());
if(isSupported) {
if(art == null) {
return 4;
} else if(art.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) {
return 6;
} else {
return 4;
}
} else {
return 0;
}
}
/**