mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-16 17:57:43 +00:00
Merge pull request #1950 from millmanorama/TL-internationalize-TreeComparator
internationalize TreeComparator
This commit is contained in:
commit
6dc456c6f1
@ -21,7 +21,6 @@ package org.sleuthkit.autopsy.timeline.ui.detailview.tree;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.Objects;
|
||||
import javafx.beans.InvalidationListener;
|
||||
import javafx.beans.Observable;
|
||||
@ -30,6 +29,7 @@ import javafx.collections.ListChangeListener;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ListCell;
|
||||
import javafx.scene.control.SelectionMode;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import javafx.scene.control.TreeCell;
|
||||
@ -72,7 +72,7 @@ final public class EventsTree extends BorderPane {
|
||||
private Label eventsTreeLabel;
|
||||
|
||||
@FXML
|
||||
private ComboBox<Comparator<TreeItem<EventBundle<?>>>> sortByBox;
|
||||
private ComboBox<TreeComparator> sortByBox;
|
||||
|
||||
public EventsTree(TimeLineController controller) {
|
||||
this.controller = controller;
|
||||
@ -128,6 +128,8 @@ final public class EventsTree extends BorderPane {
|
||||
|
||||
sortByBox.getItems().setAll(Arrays.asList(TreeComparator.Description, TreeComparator.Count));
|
||||
sortByBox.getSelectionModel().select(TreeComparator.Description);
|
||||
sortByBox.setCellFactory(listView -> new TreeComparatorCell());
|
||||
sortByBox.setButtonCell(new TreeComparatorCell());
|
||||
sortByBox.getSelectionModel().selectedItemProperty().addListener((Observable o) -> {
|
||||
getRoot().resort(TreeComparator.Type.reversed().thenComparing(sortByBox.getSelectionModel().getSelectedItem()), true);
|
||||
});
|
||||
@ -249,4 +251,17 @@ final public class EventsTree extends BorderPane {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static private class TreeComparatorCell extends ListCell<TreeComparator> {
|
||||
|
||||
@Override
|
||||
protected void updateItem(TreeComparator item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (empty || item == null) {
|
||||
setText(null);
|
||||
} else {
|
||||
setText(item.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,27 +20,41 @@ package org.sleuthkit.autopsy.timeline.ui.detailview.tree;
|
||||
|
||||
import java.util.Comparator;
|
||||
import javafx.scene.control.TreeItem;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.timeline.datamodel.EventBundle;
|
||||
import org.sleuthkit.autopsy.timeline.datamodel.eventtype.EventType;
|
||||
|
||||
@NbBundle.Messages({"TreeComparator.Description.displayName=Description",
|
||||
"TreeComparator.Count.displayName=Count",
|
||||
"TreeComparator.Type.displayName=Type"})
|
||||
enum TreeComparator implements Comparator<TreeItem<EventBundle<?>>> {
|
||||
|
||||
Description {
|
||||
Description(Bundle.TreeComparator_Description_displayName()) {
|
||||
@Override
|
||||
public int compare(TreeItem<EventBundle<?>> o1, TreeItem<EventBundle<?>> o2) {
|
||||
return o1.getValue().getDescription().compareTo(o2.getValue().getDescription());
|
||||
}
|
||||
},
|
||||
Count {
|
||||
Count(Bundle.TreeComparator_Count_displayName()) {
|
||||
@Override
|
||||
public int compare(TreeItem<EventBundle<?>> o1, TreeItem<EventBundle<?>> o2) {
|
||||
return Long.compare(o2.getValue().getCount(), o1.getValue().getCount());
|
||||
}
|
||||
},
|
||||
Type {
|
||||
Type(Bundle.TreeComparator_Type_displayName()) {
|
||||
@Override
|
||||
public int compare(TreeItem<EventBundle<?>> o1, TreeItem<EventBundle<?>> o2) {
|
||||
return EventType.getComparator().compare(o1.getValue().getEventType(), o2.getValue().getEventType());
|
||||
}
|
||||
};
|
||||
|
||||
private final String displayName;
|
||||
|
||||
private TreeComparator(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user