remove checkbox, reorder initialization

This commit is contained in:
millmanorama 2018-08-20 16:04:51 +02:00
parent 5f823efc1f
commit d99712e205
2 changed files with 31 additions and 39 deletions

View File

@ -17,7 +17,7 @@
<items> <items>
<HBox alignment="CENTER" spacing="5.0"> <HBox alignment="CENTER" spacing="5.0">
<children> <children>
<CheckBox fx:id="filterDataSourcesCheckBox" mnemonicParsing="false" text="Filter DataSources:"> <Label mnemonicParsing="false" text=" Data Source: ">
<graphic> <graphic>
<ImageView fitHeight="16.0" fitWidth="16.0" pickOnBounds="true" preserveRatio="true"> <ImageView fitHeight="16.0" fitWidth="16.0" pickOnBounds="true" preserveRatio="true">
<image> <image>
@ -25,7 +25,7 @@
</image> </image>
</ImageView> </ImageView>
</graphic> </graphic>
</CheckBox> </Label>
<ComboBox fx:id="dataSourceComboBox" editable="false" /> <ComboBox fx:id="dataSourceComboBox" editable="false" />
</children> </children>

View File

@ -21,18 +21,18 @@ package org.sleuthkit.autopsy.imagegallery.gui;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.logging.Level; import java.util.logging.Level;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.beans.InvalidationListener; import javafx.beans.InvalidationListener;
import javafx.beans.Observable; import javafx.beans.Observable;
import javafx.beans.property.DoubleProperty; import javafx.beans.property.DoubleProperty;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.geometry.Insets; import javafx.geometry.Insets;
import javafx.scene.Cursor; import javafx.scene.Cursor;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox; import javafx.scene.control.ComboBox;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.ListCell; import javafx.scene.control.ListCell;
@ -71,45 +71,36 @@ public class Toolbar extends ToolBar {
private static final int SIZE_SLIDER_DEFAULT = 100; private static final int SIZE_SLIDER_DEFAULT = 100;
@FXML @FXML
private CheckBox filterDataSourcesCheckBox; private ComboBox<Optional<DataSource>> dataSourceComboBox;
@FXML
private ComboBox<DataSource> dataSourceComboBox;
@FXML @FXML
private ImageView sortHelpImageView; private ImageView sortHelpImageView;
@FXML @FXML
private ComboBox<DrawableAttribute<?>> groupByBox; private ComboBox<DrawableAttribute<?>> groupByBox;
@FXML @FXML
private Slider sizeSlider; private Slider sizeSlider;
@FXML @FXML
private SplitMenuButton catGroupMenuButton; private SplitMenuButton catGroupMenuButton;
@FXML @FXML
private SplitMenuButton tagGroupMenuButton; private SplitMenuButton tagGroupMenuButton;
@FXML @FXML
private Label groupByLabel; private Label groupByLabel;
@FXML @FXML
private Label tagImageViewLabel; private Label tagImageViewLabel;
@FXML @FXML
private Label categoryImageViewLabel; private Label categoryImageViewLabel;
@FXML @FXML
private Label thumbnailSizeLabel; private Label thumbnailSizeLabel;
private final ImageGalleryController controller;
private SortChooser<DrawableGroup, GroupSortBy> sortChooser; private SortChooser<DrawableGroup, GroupSortBy> sortChooser;
private final ImageGalleryController controller;
private final ObservableList<Optional<DataSource>> dataSources = FXCollections.observableArrayList();
private final InvalidationListener queryInvalidationListener = new InvalidationListener() { private final InvalidationListener queryInvalidationListener = new InvalidationListener() {
@Override @Override
public void invalidated(Observable invalidated) { public void invalidated(Observable invalidated) {
controller.getGroupManager().regroup( controller.getGroupManager().regroup(
//dataSourceComboBox.getSelectionModel().getSelectedItem(), TODO-1010/7: incorporate the selected datasource into this call.
groupByBox.getSelectionModel().getSelectedItem(), groupByBox.getSelectionModel().getSelectedItem(),
sortChooser.getComparator(), sortChooser.getComparator(),
sortChooser.getSortOrder(), sortChooser.getSortOrder(),
@ -117,10 +108,6 @@ public class Toolbar extends ToolBar {
} }
}; };
public DoubleProperty thumbnailSizeProperty() {
return sizeSlider.valueProperty();
}
@FXML @FXML
@NbBundle.Messages({"Toolbar.groupByLabel=Group By:", @NbBundle.Messages({"Toolbar.groupByLabel=Group By:",
"Toolbar.sortByLabel=Sort By:", "Toolbar.sortByLabel=Sort By:",
@ -133,7 +120,6 @@ public class Toolbar extends ToolBar {
"Toolbar.sortHelpTitle=Group Sorting",}) "Toolbar.sortHelpTitle=Group Sorting",})
void initialize() { void initialize() {
assert groupByBox != null : "fx:id=\"groupByBox\" was not injected: check your FXML file 'Toolbar.fxml'."; assert groupByBox != null : "fx:id=\"groupByBox\" was not injected: check your FXML file 'Toolbar.fxml'.";
assert filterDataSourcesCheckBox != null : "fx:id=\"filterDataSourcesCheckBox\" was not injected: check your FXML file 'Toolbar.fxml'.";
assert dataSourceComboBox != null : "fx:id=\"dataSourceComboBox\" was not injected: check your FXML file 'Toolbar.fxml'."; assert dataSourceComboBox != null : "fx:id=\"dataSourceComboBox\" was not injected: check your FXML file 'Toolbar.fxml'.";
assert sortHelpImageView != null : "fx:id=\"sortHelpImageView\" was not injected: check your FXML file 'Toolbar.fxml'."; assert sortHelpImageView != null : "fx:id=\"sortHelpImageView\" was not injected: check your FXML file 'Toolbar.fxml'.";
assert tagImageViewLabel != null : "fx:id=\"tagImageViewLabel\" was not injected: check your FXML file 'Toolbar.fxml'."; assert tagImageViewLabel != null : "fx:id=\"tagImageViewLabel\" was not injected: check your FXML file 'Toolbar.fxml'.";
@ -147,23 +133,21 @@ public class Toolbar extends ToolBar {
Platform.runLater(() -> syncGroupControlsEnabledState(newViewState)); Platform.runLater(() -> syncGroupControlsEnabledState(newViewState));
}); });
syncGroupControlsEnabledState(controller.viewState().get()); syncGroupControlsEnabledState(controller.viewState().get());
dataSourceComboBox.disableProperty().bind(filterDataSourcesCheckBox.selectedProperty().not());
dataSourceComboBox.setCellFactory(param -> new DataSourceCell()); dataSourceComboBox.setCellFactory(param -> new DataSourceCell());
dataSourceComboBox.setButtonCell(new DataSourceCell()); dataSourceComboBox.setButtonCell(new DataSourceCell());
dataSourceComboBox.setItems(dataSources);
dataSourceComboBox.getSelectionModel().selectedItemProperty()
.addListener((ObservableValue<? extends DataSource> observable, DataSource oldValue, DataSource newValue) -> {
/* TODO-1010/7: record newly selected datasource(id)
* somewhere? controller? probably setting that property
* will trigger a refresh...
*/
});
try { try {
/* /*
* TODO-1005: Getting the datasources and tShe tagnames are Db * TODO-1005: Getting the datasources and the tagnames are Db
* querries. We should probably push them off to a BG thread. * querries. We should probably push them off to a BG thread.
*/ */
dataSourceComboBox.setItems(FXCollections.observableArrayList(controller.getSleuthKitCase().getDataSources())); dataSources.add(Optional.empty());
controller.getSleuthKitCase().getDataSources()
.forEach(dataSource -> dataSources.add(Optional.of(dataSource)));
/* TODO: 1010/7 push data source selected in dialog into UI */
dataSourceComboBox.getSelectionModel().selectFirst();
TagGroupAction followUpGroupAction = new TagGroupAction(controller.getTagsManager().getFollowUpTagName(), controller); TagGroupAction followUpGroupAction = new TagGroupAction(controller.getTagsManager().getFollowUpTagName(), controller);
tagGroupMenuButton.setOnAction(followUpGroupAction); tagGroupMenuButton.setOnAction(followUpGroupAction);
@ -213,7 +197,7 @@ public class Toolbar extends ToolBar {
groupByBox.setItems(FXCollections.observableList(DrawableAttribute.getGroupableAttrs())); groupByBox.setItems(FXCollections.observableList(DrawableAttribute.getGroupableAttrs()));
groupByBox.getSelectionModel().select(DrawableAttribute.PATH); groupByBox.getSelectionModel().select(DrawableAttribute.PATH);
groupByBox.getSelectionModel().selectedItemProperty().addListener(queryInvalidationListener);
groupByBox.disableProperty().bind(ImageGalleryController.getDefault().regroupDisabled()); groupByBox.disableProperty().bind(ImageGalleryController.getDefault().regroupDisabled());
groupByBox.setCellFactory(listView -> new AttributeListCell()); groupByBox.setCellFactory(listView -> new AttributeListCell());
groupByBox.setButtonCell(new AttributeListCell()); groupByBox.setButtonCell(new AttributeListCell());
@ -228,7 +212,6 @@ public class Toolbar extends ToolBar {
queryInvalidationListener.invalidated(observable); queryInvalidationListener.invalidated(observable);
}); });
sortChooser.sortOrderProperty().addListener(queryInvalidationListener);
sortChooser.setComparator(controller.getGroupManager().getSortBy()); sortChooser.setComparator(controller.getGroupManager().getSortBy());
getItems().add(2, sortChooser); getItems().add(2, sortChooser);
sortHelpImageView.setCursor(Cursor.HAND); sortHelpImageView.setCursor(Cursor.HAND);
@ -240,6 +223,15 @@ public class Toolbar extends ToolBar {
Bundle.Toolbar_sortHelpTitle(), Bundle.Toolbar_sortHelpTitle(),
sortHelpImageView.getImage(), text); sortHelpImageView.getImage(), text);
}); });
dataSourceComboBox.getSelectionModel().selectedItemProperty().addListener(queryInvalidationListener);
groupByBox.getSelectionModel().selectedItemProperty().addListener(queryInvalidationListener);
sortChooser.sortOrderProperty().addListener(queryInvalidationListener);
}
public DoubleProperty thumbnailSizeProperty() {
return sizeSlider.valueProperty();
} }
/** /**
@ -291,15 +283,15 @@ public class Toolbar extends ToolBar {
/** /**
* Cell used to represent a DataSource in the dataSourceComboBoc * Cell used to represent a DataSource in the dataSourceComboBoc
*/ */
static private class DataSourceCell extends ListCell<DataSource> { static private class DataSourceCell extends ListCell<Optional<DataSource>> {
@Override @Override
protected void updateItem(DataSource item, boolean empty) { protected void updateItem(Optional<DataSource> item, boolean empty) {
super.updateItem(item, empty); super.updateItem(item, empty);
if (empty || item == null) { if (empty || item == null) {
setText("All Data Sources"); setText("");
} else { } else {
setText(item.getName()); setText(item.map(DataSource::getName).orElse("All"));
} }
} }
} }