Merge pull request #1848 from millmanorama/IG-group-sort-bug-fix

maintain proper sorting in tree / list
This commit is contained in:
Richard Cordovano 2016-01-28 15:36:31 -05:00
commit 7600d56ad7
4 changed files with 7 additions and 5 deletions

View File

@ -72,16 +72,19 @@ final public class GroupTree extends NavPanel<TreeItem<GroupTreeNode>> {
groupTree.setCellFactory(treeView -> new GroupTreeCell(getSortByBox().getSelectionModel().selectedItemProperty())); groupTree.setCellFactory(treeView -> new GroupTreeCell(getSortByBox().getSelectionModel().selectedItemProperty()));
groupTree.setShowRoot(false); groupTree.setShowRoot(false);
getGroupManager().getAnalyzedGroups().addListener((ListChangeListener.Change<? extends DrawableGroup> change) -> { getGroupManager().getAnalyzedGroups().addListener((ListChangeListener.Change<? extends DrawableGroup> change) -> {
while (change.next()) { while (change.next()) {
change.getAddedSubList().stream().forEach(this::insertGroup); change.getAddedSubList().stream().forEach(this::insertGroup);
change.getRemoved().stream().forEach(this::removeFromTree); change.getRemoved().stream().forEach(this::removeFromTree);
} }
sortGroups();
}); });
for (DrawableGroup g : getGroupManager().getAnalyzedGroups()) { for (DrawableGroup g : getGroupManager().getAnalyzedGroups()) {
insertGroup(g); insertGroup(g);
} }
sortGroups();
} }
/** /**

View File

@ -105,6 +105,7 @@ class GroupTreeItem extends TreeItem<GroupTreeNode> {
Platform.runLater(() -> { Platform.runLater(() -> {
getChildren().add(newTreeItem); getChildren().add(newTreeItem);
getChildren().sort(Comparator.comparing(treeItem -> treeItem.getValue().getGroup(), Comparator.nullsLast(comp)));
}); });
return newTreeItem; return newTreeItem;
}); });
@ -122,7 +123,7 @@ class GroupTreeItem extends TreeItem<GroupTreeNode> {
final GroupTreeItem newTreeItem = new GroupTreeItem(t, g, true); final GroupTreeItem newTreeItem = new GroupTreeItem(t, g, true);
Platform.runLater(() -> { Platform.runLater(() -> {
getChildren().add(newTreeItem); getChildren().add(newTreeItem);
getChildren().sort(Comparator.comparing(treeItem -> treeItem.getValue().getGroup(), comp)); getChildren().sort(Comparator.comparing(treeItem -> treeItem.getValue().getGroup(), Comparator.nullsLast(comp)));
}); });
return newTreeItem; return newTreeItem;
}); });
@ -171,7 +172,7 @@ class GroupTreeItem extends TreeItem<GroupTreeNode> {
@ThreadConfined(type = ThreadConfined.ThreadType.JFX) @ThreadConfined(type = ThreadConfined.ThreadType.JFX)
synchronized void resortChildren(Comparator<DrawableGroup> newComp) { synchronized void resortChildren(Comparator<DrawableGroup> newComp) {
this.comp = newComp; this.comp = newComp;
getChildren().sort(Comparator.comparing(treeItem -> treeItem.getValue().getGroup(), comp)); getChildren().sort(Comparator.comparing(treeItem -> treeItem.getValue().getGroup(), Comparator.nullsLast(comp)));
for (GroupTreeItem ti : childMap.values()) { for (GroupTreeItem ti : childMap.values()) {
ti.resortChildren(comp); ti.resortChildren(comp);
} }

View File

@ -75,12 +75,11 @@ final public class HashHitGroupList extends NavPanel<DrawableGroup> {
setGraphic(new ImageView("org/sleuthkit/autopsy/imagegallery/images/hashset_hits.png")); setGraphic(new ImageView("org/sleuthkit/autopsy/imagegallery/images/hashset_hits.png"));
getBorderPane().setCenter(groupList); getBorderPane().setCenter(groupList);
sorted = getController().getGroupManager().getAnalyzedGroups().filtered((DrawableGroup t) -> t.getHashSetHitsCount() > 0).sorted(); sorted = getController().getGroupManager().getAnalyzedGroups().filtered((DrawableGroup t) -> t.getHashSetHitsCount() > 0).sorted(getDefaultComparator());
groupList.setCellFactory(treeView -> new GroupListCell(getSortByBox().getSelectionModel().selectedItemProperty())); groupList.setCellFactory(treeView -> new GroupListCell(getSortByBox().getSelectionModel().selectedItemProperty()));
groupList.setItems(sorted); groupList.setItems(sorted);
} }
@ThreadConfined(type = ThreadConfined.ThreadType.JFX) @ThreadConfined(type = ThreadConfined.ThreadType.JFX)

View File

@ -90,7 +90,6 @@ abstract class NavPanel<X> extends Tab {
} else { } else {
categoryManager.unregisterListener(NavPanel.this); categoryManager.unregisterListener(NavPanel.this);
} }
}); });
//keep selection in sync with controller //keep selection in sync with controller