Merge pull request #1989 from millmanorama/IG-don't-reset-toolbar-when-ig-has-not-been-launched

toolbar is no longer a lazily initialized singleton, it is no lon…
This commit is contained in:
Richard Cordovano 2016-02-25 17:22:17 -05:00
commit 6e4c7b4b15
5 changed files with 26 additions and 23 deletions

View File

@ -35,6 +35,7 @@ import javafx.beans.Observable;
import javafx.beans.property.ReadOnlyBooleanProperty; import javafx.beans.property.ReadOnlyBooleanProperty;
import javafx.beans.property.ReadOnlyBooleanWrapper; import javafx.beans.property.ReadOnlyBooleanWrapper;
import javafx.beans.property.ReadOnlyDoubleProperty; import javafx.beans.property.ReadOnlyDoubleProperty;
import javafx.beans.property.ReadOnlyDoubleWrapper;
import javafx.beans.property.ReadOnlyIntegerProperty; import javafx.beans.property.ReadOnlyIntegerProperty;
import javafx.beans.property.ReadOnlyIntegerWrapper; import javafx.beans.property.ReadOnlyIntegerWrapper;
import javafx.beans.property.ReadOnlyObjectProperty; import javafx.beans.property.ReadOnlyObjectProperty;
@ -95,6 +96,7 @@ public final class ImageGalleryController implements Executor {
private final Executor execDelegate = Executors.newSingleThreadExecutor(); private final Executor execDelegate = Executors.newSingleThreadExecutor();
private Runnable showTree; private Runnable showTree;
private Toolbar toolbar;
@Override @Override
public void execute(Runnable command) { 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 stale = new ReadOnlyBooleanWrapper(false);
private final ReadOnlyBooleanWrapper metaDataCollapsed = new ReadOnlyBooleanWrapper(false); private final ReadOnlyBooleanWrapper metaDataCollapsed = new ReadOnlyBooleanWrapper(false);
private final ReadOnlyDoubleWrapper thumbnailSize = new ReadOnlyDoubleWrapper(100);
private final FileIDSelectionModel selectionModel = new FileIDSelectionModel(this); private final FileIDSelectionModel selectionModel = new FileIDSelectionModel(this);
@ -161,6 +164,10 @@ public final class ImageGalleryController implements Executor {
this.metaDataCollapsed.set(metaDataCollapsed); this.metaDataCollapsed.set(metaDataCollapsed);
} }
public ReadOnlyDoubleProperty thumbnailSizeProperty() {
return thumbnailSize.getReadOnlyProperty();
}
private GroupViewState getViewState() { private GroupViewState getViewState() {
return historyManager.getCurrentState(); return historyManager.getCurrentState();
} }
@ -418,7 +425,9 @@ public final class ImageGalleryController implements Executor {
dbWorkerThread = null; dbWorkerThread = null;
dbWorkerThread = restartWorker(); dbWorkerThread = restartWorker();
Toolbar.getDefault(this).reset(); if (toolbar != null) {
toolbar.reset();
}
if (db != null) { if (db != null) {
db.closeDBCon(); db.closeDBCon();
@ -453,6 +462,14 @@ public final class ImageGalleryController implements Executor {
Platform.runLater(this::checkForGroups); 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() { public ReadOnlyDoubleProperty regroupProgress() {
return groupManager.regroupProgress(); return groupManager.regroupProgress();
} }

View File

@ -148,7 +148,8 @@ public final class ImageGalleryTopComponent extends TopComponent implements Expl
fullUIStack.getChildren().add(borderPane); fullUIStack.getChildren().add(borderPane);
splitPane = new SplitPane(); splitPane = new SplitPane();
borderPane.setCenter(splitPane); borderPane.setCenter(splitPane);
borderPane.setTop(Toolbar.getDefault(controller)); Toolbar toolbar = new Toolbar(controller);
borderPane.setTop(toolbar);
borderPane.setBottom(new StatusBar(controller)); borderPane.setBottom(new StatusBar(controller));
metaDataTable = new MetaDataPane(controller); metaDataTable = new MetaDataPane(controller);
@ -168,6 +169,7 @@ public final class ImageGalleryTopComponent extends TopComponent implements Expl
splitPane.setDividerPositions(0.1, 1.0); splitPane.setDividerPositions(0.1, 1.0);
ImageGalleryController.getDefault().setStacks(fullUIStack, centralStack); ImageGalleryController.getDefault().setStacks(fullUIStack, centralStack);
ImageGalleryController.getDefault().setToolbar(toolbar);
ImageGalleryController.getDefault().setShowTree(() -> tabPane.getSelectionModel().select(groupTree)); ImageGalleryController.getDefault().setShowTree(() -> tabPane.getSelectionModel().select(groupTree));
}); });
} }

View File

@ -26,7 +26,6 @@ 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.property.SimpleObjectProperty;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.ComboBox; import javafx.scene.control.ComboBox;
@ -35,7 +34,6 @@ import javafx.scene.control.MenuItem;
import javafx.scene.control.Slider; import javafx.scene.control.Slider;
import javafx.scene.control.SplitMenuButton; import javafx.scene.control.SplitMenuButton;
import javafx.scene.control.ToolBar; import javafx.scene.control.ToolBar;
import javax.swing.SortOrder;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.imagegallery.FXMLConstructor; import org.sleuthkit.autopsy.imagegallery.FXMLConstructor;
@ -82,10 +80,6 @@ public class Toolbar extends ToolBar {
@FXML @FXML
private Label thumbnailSizeLabel; private Label thumbnailSizeLabel;
private static Toolbar instance;
private final SimpleObjectProperty<SortOrder> orderProperty = new SimpleObjectProperty<>(SortOrder.ASCENDING);
private final ImageGalleryController controller; private final ImageGalleryController controller;
private SortChooser<DrawableGroup, GroupSortBy> sortChooser; private SortChooser<DrawableGroup, GroupSortBy> sortChooser;
@ -99,17 +93,10 @@ public class Toolbar extends ToolBar {
} }
}; };
public DoubleProperty sizeSliderValue() { public DoubleProperty thumbnailSizeProperty() {
return sizeSlider.valueProperty(); return sizeSlider.valueProperty();
} }
static synchronized public Toolbar getDefault(ImageGalleryController controller) {
if (instance == null) {
instance = new Toolbar(controller);
}
return instance;
}
@FXML @FXML
@NbBundle.Messages({"Toolbar.groupByLabel=Group By:", @NbBundle.Messages({"Toolbar.groupByLabel=Group By:",
"Toolbar.sortByLabel=Sort By:", "Toolbar.sortByLabel=Sort By:",
@ -156,7 +143,6 @@ public class Toolbar extends ToolBar {
catGroupMenuButton.getItems().setAll(categoryMenues); catGroupMenuButton.getItems().setAll(categoryMenues);
} }
}); });
groupByLabel.setText(Bundle.Toolbar_groupByLabel()); groupByLabel.setText(Bundle.Toolbar_groupByLabel());
tagImageViewLabel.setText(Bundle.Toolbar_tagImageViewLabel()); 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; this.controller = controller;
FXMLConstructor.construct(this, "Toolbar.fxml"); //NON-NLS FXMLConstructor.construct(this, "Toolbar.fxml"); //NON-NLS
} }

View File

@ -35,7 +35,6 @@ import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.imagegallery.FXMLConstructor; import org.sleuthkit.autopsy.imagegallery.FXMLConstructor;
import org.sleuthkit.autopsy.imagegallery.ImageGalleryController; import org.sleuthkit.autopsy.imagegallery.ImageGalleryController;
import org.sleuthkit.autopsy.imagegallery.datamodel.DrawableFile; 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, * 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); setCache(true);
setCacheHint(CacheHint.SPEED); setCacheHint(CacheHint.SPEED);
nameLabel.prefWidthProperty().bind(imageView.fitWidthProperty()); nameLabel.prefWidthProperty().bind(imageView.fitWidthProperty());
imageView.fitHeightProperty().bind(Toolbar.getDefault(getController()).sizeSliderValue()); imageView.fitHeightProperty().bind(getController().thumbnailSizeProperty());
imageView.fitWidthProperty().bind(Toolbar.getDefault(getController()).sizeSliderValue()); imageView.fitWidthProperty().bind(getController().thumbnailSizeProperty());
selectionModel.lastSelectedProperty().addListener(new WeakChangeListener<>(lastSelectionListener)); selectionModel.lastSelectedProperty().addListener(new WeakChangeListener<>(lastSelectionListener));

View File

@ -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.GroupViewMode;
import org.sleuthkit.autopsy.imagegallery.datamodel.grouping.GroupViewState; import org.sleuthkit.autopsy.imagegallery.datamodel.grouping.GroupViewState;
import org.sleuthkit.autopsy.imagegallery.gui.GuiUtils; import org.sleuthkit.autopsy.imagegallery.gui.GuiUtils;
import org.sleuthkit.autopsy.imagegallery.gui.Toolbar;
import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskCoreException;
/** /**
@ -418,7 +417,7 @@ public class GroupPane extends BorderPane {
flashAnimation.setAutoReverse(true); flashAnimation.setAutoReverse(true);
//configure gridView cell properties //configure gridView cell properties
DoubleBinding cellSize = Toolbar.getDefault(controller).sizeSliderValue().add(75); DoubleBinding cellSize = controller.thumbnailSizeProperty().add(75);
gridView.cellHeightProperty().bind(cellSize); gridView.cellHeightProperty().bind(cellSize);
gridView.cellWidthProperty().bind(cellSize); gridView.cellWidthProperty().bind(cellSize);
gridView.setCellFactory((GridView<Long> param) -> new DrawableCell()); gridView.setCellFactory((GridView<Long> param) -> new DrawableCell());