mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-19 11:07:43 +00:00
clean up selection management in TimeLineTopComponent and ListTimeline
This commit is contained in:
parent
536d772502
commit
c5bbe274fb
@ -19,7 +19,6 @@
|
|||||||
package org.sleuthkit.autopsy.timeline;
|
package org.sleuthkit.autopsy.timeline;
|
||||||
|
|
||||||
import java.beans.PropertyVetoException;
|
import java.beans.PropertyVetoException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@ -105,29 +104,28 @@ public final class TimeLineTopComponent extends TopComponent implements Explorer
|
|||||||
switch (controller.getViewMode()) {
|
switch (controller.getViewMode()) {
|
||||||
case LIST:
|
case LIST:
|
||||||
|
|
||||||
Children children = new Children.Array();
|
//make an array of EventNodes for the selected events
|
||||||
ArrayList<EventNode> childList = new ArrayList<>();
|
EventNode[] childArray = new EventNode[selectedEventIDs.size()];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (Long t : selectedEventIDs) {
|
for (int i = 0; i < selectedEventIDs.size(); i++) {
|
||||||
childList.add(EventNode.createEventNode(t, controller.getEventsModel()));
|
childArray[i] = EventNode.createEventNode(selectedEventIDs.get(i), controller.getEventsModel());
|
||||||
}
|
}
|
||||||
EventNode[] toArray = childList.toArray(new EventNode[childList.size()]);
|
Children children = new Children.Array();
|
||||||
|
children.add(childArray);
|
||||||
children.add(toArray);
|
|
||||||
|
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
//set node as selected for actions
|
//set generic container node as root context
|
||||||
em.setRootContext(new AbstractNode(children));
|
em.setRootContext(new AbstractNode(children));
|
||||||
try {
|
try {
|
||||||
em.setSelectedNodes(toArray);
|
//set selected nodes for actions
|
||||||
|
em.setSelectedNodes(childArray);
|
||||||
} catch (PropertyVetoException ex) {
|
} catch (PropertyVetoException ex) {
|
||||||
//I don't know why this would ever happen.
|
//I don't know why this would ever happen.
|
||||||
LOGGER.log(Level.SEVERE, "Selecting the event node was vetoed.", ex); // NON-NLS
|
LOGGER.log(Level.SEVERE, "Selecting the event node was vetoed.", ex); // NON-NLS
|
||||||
}
|
}
|
||||||
//push into content viewer.
|
//if there is only one event selected push it into content viewer.
|
||||||
if (selectedEventIDs.size() == 1) {
|
if (selectedEventIDs.size() == 1) {
|
||||||
contentViewerPanel.setNode(toArray[0]);
|
contentViewerPanel.setNode(childArray[0]);
|
||||||
} else {
|
} else {
|
||||||
contentViewerPanel.setNode(null);
|
contentViewerPanel.setNode(null);
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.timeline.ui.listvew;
|
package org.sleuthkit.autopsy.timeline.ui.listvew;
|
||||||
|
|
||||||
|
import com.google.common.collect.FluentIterable;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -25,7 +26,6 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.beans.Observable;
|
import javafx.beans.Observable;
|
||||||
import javafx.beans.binding.Bindings;
|
import javafx.beans.binding.Bindings;
|
||||||
@ -140,14 +140,11 @@ class ListTimeline extends BorderPane {
|
|||||||
table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
||||||
|
|
||||||
table.getSelectionModel().getSelectedItems().addListener((Observable observable) -> {
|
table.getSelectionModel().getSelectedItems().addListener((Observable observable) -> {
|
||||||
if (table.getSelectionModel().getSelectedItems().size() == 1) {
|
selectedEventIDs.setAll(
|
||||||
selectedEventIDs.setAll(Iterables.getFirst(table.getSelectionModel().getSelectedItem().getEventIDs(), 0L));
|
FluentIterable.from(table.getSelectionModel().getSelectedItems())
|
||||||
} else {
|
.filter(Objects::nonNull)
|
||||||
selectedEventIDs.setAll(table.getSelectionModel().getSelectedItems().stream()
|
.transform(MergedEvent::getRepresentitiveEventID)
|
||||||
.filter(Objects::nonNull)
|
.toSet());
|
||||||
.flatMap(mEvent -> mEvent.getEventIDs().stream())
|
|
||||||
.collect(Collectors.toSet()));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user