fix bug in TreeCell generation for non-path groups

This commit is contained in:
jmillman 2014-09-03 12:09:52 -04:00
parent 4b6d1a9e55
commit b814b9aee3
2 changed files with 28 additions and 21 deletions

View File

@ -12,13 +12,17 @@ import org.apache.commons.lang3.StringUtils;
import org.sleuthkit.autopsy.imageanalyzer.datamodel.DrawableAttribute; import org.sleuthkit.autopsy.imageanalyzer.datamodel.DrawableAttribute;
import org.sleuthkit.autopsy.imageanalyzer.grouping.Grouping; import org.sleuthkit.autopsy.imageanalyzer.grouping.Grouping;
/** A {@link Node} in the tree that listens to its associated group. Manages /**
* A {@link Node} in the tree that listens to its associated group. Manages
* visual representation of TreeNode in Tree. Listens to properties of group * visual representation of TreeNode in Tree. Listens to properties of group
* that don't impact hierarchy and updates ui to reflect them */ * that don't impact hierarchy and updates ui to reflect them
*/
class GroupTreeCell extends TreeCell<TreeNode> { class GroupTreeCell extends TreeCell<TreeNode> {
/** icon to use if this cell's TreeNode doesn't represent a group but just a /**
* folder(with no DrawableFiles) in the hierarchy. */ * icon to use if this cell's TreeNode doesn't represent a group but just a
* folder(with no DrawableFiles) in the hierarchy.
*/
private static final Image EMPTY_FOLDER_ICON = new Image("org/sleuthkit/autopsy/imageanalyzer/images/folder.png"); private static final Image EMPTY_FOLDER_ICON = new Image("org/sleuthkit/autopsy/imageanalyzer/images/folder.png");
public GroupTreeCell() { public GroupTreeCell() {
@ -61,22 +65,21 @@ class GroupTreeCell extends TreeCell<TreeNode> {
} }
} }
/** @return the Numerator of the count to append to the group name = number /**
* of hashset hits + "/" */ * @return the Numerator of the count to append to the group name = number
* of hashset hits + "/"
*/
synchronized private String getNumerator() { synchronized private String getNumerator() {
try { final String numerator = (getItem().getGroup().groupKey.getAttribute() != DrawableAttribute.HASHSET)
final String numerator = (getItem().getGroup().groupKey.getAttribute() != DrawableAttribute.HASHSET) ? getItem().getGroup().getFilesWithHashSetHitsCount() + "/"
? getItem().getGroup().getFilesWithHashSetHitsCount() + "/" : "";
: ""; return numerator;
return numerator;
} catch (NullPointerException ex) {
return "";
}
} }
/** @return the Denominator of the count to append to the group name = /**
* number of files in group */ * @return the Denominator of the count to append to the group name = number
* of files in group
*/
synchronized private Integer getDenominator() { synchronized private Integer getDenominator() {
try { try {
return getItem().getGroup().getSize(); return getItem().getGroup().getSize();

View File

@ -230,12 +230,16 @@ public class NavPanel extends TabPane {
@SuppressWarnings("fallthrough") @SuppressWarnings("fallthrough")
private static List<String> groupingToPath(Grouping g) { private static List<String> groupingToPath(Grouping g) {
String path = g.groupKey.getValueDisplayName(); if (g.groupKey.getAttribute() == DrawableAttribute.PATH) {
String path = g.groupKey.getValueDisplayName();
String cleanPath = StringUtils.stripStart(path, "/"); String cleanPath = StringUtils.stripStart(path, "/");
String[] tokens = cleanPath.split("/"); String[] tokens = cleanPath.split("/");
return Arrays.asList(tokens); return Arrays.asList(tokens);
} else {
return Arrays.asList(g.groupKey.getValueDisplayName());
}
} }
private void insertIntoNavTree(Grouping g) { private void insertIntoNavTree(Grouping g) {