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:
- 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
- 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).

View File

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

View File

@ -83,16 +83,15 @@ public interface DataContentViewer {
* Checks whether the given viewer is preferred for the Node.
* 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 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 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
* 0 means not supported
* 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
* 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);
// remember the viewer with the highest preference value
int currentPreferred = dcv.isPreferred(selectedNode, true);
int currentPreferred = dcv.isPreferred(selectedNode);
if (currentPreferred > maxPreferred) {
preferredViewerIndex = i;
maxPreferred = currentPreferred;
@ -258,8 +258,8 @@ public class DataContentPanel extends javax.swing.JPanel implements DataContent,
return this.wrapped.isSupported(node);
}
int isPreferred(Node node, boolean isSupported) {
return this.wrapped.isPreferred(node, isSupported);
int isPreferred(Node node) {
return this.wrapped.isPreferred(node);
}
}

View File

@ -326,9 +326,8 @@ public class DataContentViewerArtifact extends javax.swing.JPanel implements Dat
}
@Override
public int isPreferred(Node node, boolean isSupported) {
public int isPreferred(Node node) {
BlackboardArtifact artifact = node.getLookup().lookup(BlackboardArtifact.class);
if(isSupported) {
if(artifact == null) {
return 3;
}
@ -336,10 +335,6 @@ public class DataContentViewerArtifact extends javax.swing.JPanel implements Dat
return 5;
}
}
else {
return 0;
}
}
/**
* 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
public int isPreferred(Node node, boolean isSupported) {
if (isSupported) {
public int isPreferred(Node node) {
return 1;
} else {
return 0;
}
}
@Override

View File

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

View File

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

View File

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

View File

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