removed isSupported from ContentViewer API

This commit is contained in:
Brian Carrier 2014-01-15 23:23:53 -05:00
parent 3f9a296a0f
commit a5de0c23b8
21 changed files with 372 additions and 397 deletions

View File

@ -1,7 +1,6 @@
Changes to make to API when we are ready to make backward incompatible changes: Changes to make to API when we are ready to make backward incompatible changes:
- HTMLReport has special API for more context on columns and special handling in REportGenerator. Change all reports to the new API. - HTMLReport has special API for more context on columns and special handling in REportGenerator. Change all reports to the new API.
- DataContentViewer.isPreferred does not need isSupported to be passed in
- DataContentViewerHex and Strings can have the public setDataView methods removed in favor of the new private ones - DataContentViewerHex and Strings can have the public setDataView methods removed in favor of the new private ones
- Content.getUniquePath() should not thrown TskException. We should deal with it in the method. - Content.getUniquePath() should not thrown TskException. We should deal with it in the method.
- Make the list of events that Case fires off to be part of an enum to group them together (like IngestManager does). - Make the list of events that Case fires off to be part of an enum to group them together (like IngestManager does).

View File

@ -185,7 +185,7 @@ public class Metadata extends javax.swing.JPanel implements DataContentViewer
} }
@Override @Override
public int isPreferred(Node node, boolean isSupported) { public int isPreferred(Node node) {
return 1; return 1;
} }
} }

View File

@ -83,16 +83,15 @@ public interface DataContentViewer {
* Checks whether the given viewer is preferred for the Node. * Checks whether the given viewer is preferred for the Node.
* This is a bit subjective, but the idea is that Autopsy wants to display * This is a bit subjective, but the idea is that Autopsy wants to display
* the most relevant tab. The more generic the viewer, the lower * the most relevant tab. The more generic the viewer, the lower
* the return value should be. * the return value should be. This will only be called on viewers that
* support the given node.
* *
* @param node Node to check for preference * @param node Node to check for preference
* @param isSupported true if the viewer is supported by the node, false otherwise
* as determined by a previous check
* @return an int (0-10) higher return means the viewer has higher priority * @return an int (0-10) higher return means the viewer has higher priority
* 0 means not supported * 0 means not supported
* 1 to 2 means the module will display all file types (such as the hex viewer) * 1 to 2 means the module will display all file types (such as the hex viewer)
* 3-10 are prioritized by Content viewer developer. Modules that operate on very * 3-10 are prioritized by Content viewer developer. Modules that operate on very
* few file types should be towards 10. * few file types should be towards 10.
*/ */
public int isPreferred(Node node, boolean isSupported); public int isPreferred(Node node);
} }

View File

@ -181,7 +181,7 @@ public class DataContentPanel extends javax.swing.JPanel implements DataContent,
jTabbedPane1.setEnabledAt(i, true); jTabbedPane1.setEnabledAt(i, true);
// remember the viewer with the highest preference value // remember the viewer with the highest preference value
int currentPreferred = dcv.isPreferred(selectedNode, true); int currentPreferred = dcv.isPreferred(selectedNode);
if (currentPreferred > maxPreferred) { if (currentPreferred > maxPreferred) {
preferredViewerIndex = i; preferredViewerIndex = i;
maxPreferred = currentPreferred; maxPreferred = currentPreferred;
@ -258,8 +258,8 @@ public class DataContentPanel extends javax.swing.JPanel implements DataContent,
return this.wrapped.isSupported(node); return this.wrapped.isSupported(node);
} }
int isPreferred(Node node, boolean isSupported) { int isPreferred(Node node) {
return this.wrapped.isPreferred(node, isSupported); return this.wrapped.isPreferred(node);
} }
} }

View File

@ -326,9 +326,8 @@ public class DataContentViewerArtifact extends javax.swing.JPanel implements Dat
} }
@Override @Override
public int isPreferred(Node node, boolean isSupported) { public int isPreferred(Node node) {
BlackboardArtifact artifact = node.getLookup().lookup(BlackboardArtifact.class); BlackboardArtifact artifact = node.getLookup().lookup(BlackboardArtifact.class);
if(isSupported) {
if(artifact == null) { if(artifact == null) {
return 3; return 3;
} }
@ -336,10 +335,6 @@ public class DataContentViewerArtifact extends javax.swing.JPanel implements Dat
return 5; return 5;
} }
} }
else {
return 0;
}
}
/** /**
* Instances of this class are simple containers for view update information generated by a background thread. * Instances of this class are simple containers for view update information generated by a background thread.

View File

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

View File

@ -226,8 +226,7 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
} }
@Override @Override
public int isPreferred(Node node, boolean isSupported) { public int isPreferred(Node node) {
if (isSupported) {
//special case, check if deleted video, then do not make it preferred //special case, check if deleted video, then do not make it preferred
AbstractFile file = node.getLookup().lookup(AbstractFile.class); AbstractFile file = node.getLookup().lookup(AbstractFile.class);
if (file == null) { if (file == null) {
@ -242,9 +241,7 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
else { else {
return 7; return 7;
} }
} else {
return 0;
}
} }
private static boolean containsExt(String name, String[] exts) { private static boolean containsExt(String name, String[] exts) {

View File

@ -484,12 +484,8 @@ public class DataContentViewerString extends javax.swing.JPanel implements DataC
} }
@Override @Override
public int isPreferred(Node node, boolean isSupported) { public int isPreferred(Node node) {
if (node != null && isSupported) {
return 1; return 1;
} else {
return 0;
}
} }
@Override @Override

View File

@ -166,10 +166,7 @@ public class SampleContentViewer extends javax.swing.JPanel implements DataConte
} }
@Override @Override
public int isPreferred(Node node, boolean isSupported) { public int isPreferred(Node node) {
if (isSupported == false) {
return 0;
}
// we return 1 since this module will operate on nearly all files // we return 1 since this module will operate on nearly all files
return 1; return 1;
} }

View File

@ -311,10 +311,9 @@ public class ExtractedContentViewer implements DataContentViewer {
} }
@Override @Override
public int isPreferred(Node node, public int isPreferred(Node node) {
boolean isSupported) {
BlackboardArtifact art = node.getLookup().lookup(BlackboardArtifact.class); BlackboardArtifact art = node.getLookup().lookup(BlackboardArtifact.class);
if (isSupported) {
if (art == null) { if (art == null) {
return 4; return 4;
} else if (art.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) { } else if (art.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) {
@ -322,9 +321,6 @@ public class ExtractedContentViewer implements DataContentViewer {
} else { } else {
return 4; return 4;
} }
} else {
return 0;
}
} }
/** /**