make tree select viewed group

This commit is contained in:
millmanorama 2018-09-06 17:40:09 +02:00
parent c96304106e
commit 3cd00b0aa0
3 changed files with 13 additions and 8 deletions

View File

@ -703,12 +703,12 @@ public class GroupManager {
DrawableAttribute attributeOfCurrentGroup
= viewedKey.map(GroupKey::getAttribute)
.orElse(null);
/* if no group or if groupbies are different or if data
* source != null and does not equal group */
if (viewedGroup.isPresent() == false
|| (getDataSource() != null && notEqual(dataSourceOfCurrentGroup, getDataSource()))
|| getGroupBy() != attributeOfCurrentGroup) {
//the current group should not be visible so ...
if (isNotEmpty(unSeenGroups)) {// show then next unseen group
controller.advance(GroupViewState.tile(unSeenGroups.get(0)));
@ -718,7 +718,7 @@ public class GroupManager {
} else { //there are no groups, clear the group area.
controller.advance(GroupViewState.tile(null));
}
} //else, the current group is for the given datasource, so just keep it in view.
}
}
} finally {
groupProgress.finish();

View File

@ -38,6 +38,7 @@ import org.sleuthkit.autopsy.imagegallery.FXMLConstructor;
import org.sleuthkit.autopsy.imagegallery.ImageGalleryController;
import org.sleuthkit.autopsy.imagegallery.datamodel.DrawableAttribute;
import org.sleuthkit.autopsy.imagegallery.datamodel.grouping.DrawableGroup;
import org.sleuthkit.autopsy.imagegallery.datamodel.grouping.GroupViewState;
/**
* Shows path based groups as a tree and others kinds of groups as a flat list (
@ -82,7 +83,12 @@ final public class GroupTree extends NavPanel<TreeItem<GroupTreeNode>> {
change.getAddedSubList().stream().forEach(this::insertGroup);
change.getRemoved().stream().forEach(this::removeFromTree);
}
Platform.runLater(this::sortGroups);
Platform.runLater(() -> {
GroupTree.this.sortGroups();
Optional.ofNullable(getController().getViewState())
.flatMap(GroupViewState::getGroup)
.ifPresent(this::setFocusedGroup);
});
});
getGroupManager().getAnalyzedGroups().forEach(this::insertGroup);

View File

@ -92,11 +92,10 @@ abstract class NavPanel<X> extends Tab {
//keep selection in sync with controller
controller.viewStateProperty().addListener(observable -> {
Platform.runLater(() -> {
Optional.ofNullable(controller.getViewState())
.flatMap(GroupViewState::getGroup)
.ifPresent(this::setFocusedGroup);
});
Platform.runLater(()
-> Optional.ofNullable(controller.getViewState())
.flatMap(GroupViewState::getGroup)
.ifPresent(this::setFocusedGroup));
});
// notify controller about group selection in this view