diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryController.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryController.java index d6cc002c63..246fb00154 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryController.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryController.java @@ -35,6 +35,7 @@ import javafx.beans.Observable; import javafx.beans.property.ReadOnlyBooleanProperty; import javafx.beans.property.ReadOnlyBooleanWrapper; import javafx.beans.property.ReadOnlyDoubleProperty; +import javafx.beans.property.ReadOnlyDoubleWrapper; import javafx.beans.property.ReadOnlyIntegerProperty; import javafx.beans.property.ReadOnlyIntegerWrapper; import javafx.beans.property.ReadOnlyObjectProperty; @@ -95,6 +96,7 @@ public final class ImageGalleryController implements Executor { private final Executor execDelegate = Executors.newSingleThreadExecutor(); private Runnable showTree; + private Toolbar toolbar; @Override public void execute(Runnable command) { @@ -134,6 +136,7 @@ public final class ImageGalleryController implements Executor { private final ReadOnlyBooleanWrapper stale = new ReadOnlyBooleanWrapper(false); private final ReadOnlyBooleanWrapper metaDataCollapsed = new ReadOnlyBooleanWrapper(false); + private final ReadOnlyDoubleWrapper thumbnailSize = new ReadOnlyDoubleWrapper(100); private final FileIDSelectionModel selectionModel = new FileIDSelectionModel(this); @@ -161,6 +164,10 @@ public final class ImageGalleryController implements Executor { this.metaDataCollapsed.set(metaDataCollapsed); } + public ReadOnlyDoubleProperty thumbnailSizeProperty() { + return thumbnailSize.getReadOnlyProperty(); + } + private GroupViewState getViewState() { return historyManager.getCurrentState(); } @@ -418,7 +425,9 @@ public final class ImageGalleryController implements Executor { dbWorkerThread = null; dbWorkerThread = restartWorker(); - Toolbar.getDefault(this).reset(); + if (toolbar != null) { + toolbar.reset(); + } if (db != null) { db.closeDBCon(); @@ -453,6 +462,14 @@ public final class ImageGalleryController implements Executor { Platform.runLater(this::checkForGroups); } + public synchronized void setToolbar(Toolbar toolbar) { + if (this.toolbar != null) { + throw new IllegalStateException("Can not set the toolbar a second time!"); + } + this.toolbar = toolbar; + thumbnailSize.bind(toolbar.thumbnailSizeProperty()); + } + public ReadOnlyDoubleProperty regroupProgress() { return groupManager.regroupProgress(); } diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryTopComponent.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryTopComponent.java index 0ccf7542f3..604d674ba0 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryTopComponent.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryTopComponent.java @@ -148,7 +148,8 @@ public final class ImageGalleryTopComponent extends TopComponent implements Expl fullUIStack.getChildren().add(borderPane); splitPane = new SplitPane(); borderPane.setCenter(splitPane); - borderPane.setTop(Toolbar.getDefault(controller)); + Toolbar toolbar = new Toolbar(controller); + borderPane.setTop(toolbar); borderPane.setBottom(new StatusBar(controller)); metaDataTable = new MetaDataPane(controller); @@ -168,6 +169,7 @@ public final class ImageGalleryTopComponent extends TopComponent implements Expl splitPane.setDividerPositions(0.1, 1.0); ImageGalleryController.getDefault().setStacks(fullUIStack, centralStack); + ImageGalleryController.getDefault().setToolbar(toolbar); ImageGalleryController.getDefault().setShowTree(() -> tabPane.getSelectionModel().select(groupTree)); }); } diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/Toolbar.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/Toolbar.java index a44411c768..55be749d20 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/Toolbar.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/Toolbar.java @@ -26,7 +26,6 @@ import javafx.application.Platform; import javafx.beans.InvalidationListener; import javafx.beans.Observable; import javafx.beans.property.DoubleProperty; -import javafx.beans.property.SimpleObjectProperty; import javafx.collections.FXCollections; import javafx.fxml.FXML; import javafx.scene.control.ComboBox; @@ -35,7 +34,6 @@ import javafx.scene.control.MenuItem; import javafx.scene.control.Slider; import javafx.scene.control.SplitMenuButton; import javafx.scene.control.ToolBar; -import javax.swing.SortOrder; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.imagegallery.FXMLConstructor; @@ -82,10 +80,6 @@ public class Toolbar extends ToolBar { @FXML private Label thumbnailSizeLabel; - private static Toolbar instance; - - private final SimpleObjectProperty orderProperty = new SimpleObjectProperty<>(SortOrder.ASCENDING); - private final ImageGalleryController controller; private SortChooser sortChooser; @@ -99,17 +93,10 @@ public class Toolbar extends ToolBar { } }; - public DoubleProperty sizeSliderValue() { + public DoubleProperty thumbnailSizeProperty() { return sizeSlider.valueProperty(); } - static synchronized public Toolbar getDefault(ImageGalleryController controller) { - if (instance == null) { - instance = new Toolbar(controller); - } - return instance; - } - @FXML @NbBundle.Messages({"Toolbar.groupByLabel=Group By:", "Toolbar.sortByLabel=Sort By:", @@ -156,7 +143,6 @@ public class Toolbar extends ToolBar { catGroupMenuButton.getItems().setAll(categoryMenues); } }); - groupByLabel.setText(Bundle.Toolbar_groupByLabel()); tagImageViewLabel.setText(Bundle.Toolbar_tagImageViewLabel()); @@ -202,7 +188,7 @@ public class Toolbar extends ToolBar { }); } - private Toolbar(ImageGalleryController controller) { + public Toolbar(ImageGalleryController controller) { this.controller = controller; FXMLConstructor.construct(this, "Toolbar.fxml"); //NON-NLS } diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/drawableviews/DrawableTile.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/drawableviews/DrawableTile.java index ea4e7ba181..29b65a0926 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/drawableviews/DrawableTile.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/drawableviews/DrawableTile.java @@ -35,7 +35,6 @@ import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.imagegallery.FXMLConstructor; import org.sleuthkit.autopsy.imagegallery.ImageGalleryController; import org.sleuthkit.autopsy.imagegallery.datamodel.DrawableFile; -import org.sleuthkit.autopsy.imagegallery.gui.Toolbar; /** * GUI component that represents a single image as a tile with an icon, a label, @@ -64,8 +63,8 @@ public class DrawableTile extends DrawableTileBase { setCache(true); setCacheHint(CacheHint.SPEED); nameLabel.prefWidthProperty().bind(imageView.fitWidthProperty()); - imageView.fitHeightProperty().bind(Toolbar.getDefault(getController()).sizeSliderValue()); - imageView.fitWidthProperty().bind(Toolbar.getDefault(getController()).sizeSliderValue()); + imageView.fitHeightProperty().bind(getController().thumbnailSizeProperty()); + imageView.fitWidthProperty().bind(getController().thumbnailSizeProperty()); selectionModel.lastSelectedProperty().addListener(new WeakChangeListener<>(lastSelectionListener)); diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/drawableviews/GroupPane.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/drawableviews/GroupPane.java index b21bbf462e..6fc8074248 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/drawableviews/GroupPane.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/drawableviews/GroupPane.java @@ -128,7 +128,6 @@ import org.sleuthkit.autopsy.imagegallery.datamodel.grouping.DrawableGroup; import org.sleuthkit.autopsy.imagegallery.datamodel.grouping.GroupViewMode; import org.sleuthkit.autopsy.imagegallery.datamodel.grouping.GroupViewState; import org.sleuthkit.autopsy.imagegallery.gui.GuiUtils; -import org.sleuthkit.autopsy.imagegallery.gui.Toolbar; import org.sleuthkit.datamodel.TskCoreException; /** @@ -418,7 +417,7 @@ public class GroupPane extends BorderPane { flashAnimation.setAutoReverse(true); //configure gridView cell properties - DoubleBinding cellSize = Toolbar.getDefault(controller).sizeSliderValue().add(75); + DoubleBinding cellSize = controller.thumbnailSizeProperty().add(75); gridView.cellHeightProperty().bind(cellSize); gridView.cellWidthProperty().bind(cellSize); gridView.setCellFactory((GridView param) -> new DrawableCell());