add pop up help to imagegallery sort controls

This commit is contained in:
millmanorama 2016-10-06 11:33:16 +02:00
parent f8a5795107
commit bc7b3d3556
3 changed files with 57 additions and 2 deletions

View File

@ -12,7 +12,7 @@
<?import javafx.scene.image.ImageView?> <?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.HBox?> <?import javafx.scene.layout.HBox?>
<fx:root minWidth="-1.0" orientation="HORIZONTAL" prefWidth="-1.0" type="javafx.scene.control.ToolBar" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1"> <fx:root minWidth="-1.0" orientation="HORIZONTAL" prefWidth="-1.0" type="javafx.scene.control.ToolBar" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1">
<items> <items>
<HBox alignment="CENTER" spacing="5.0"> <HBox alignment="CENTER" spacing="5.0">
<children> <children>
@ -25,6 +25,11 @@
</children> </children>
</HBox> </HBox>
<ImageView fx:id="sortHelpImageView" fitHeight="16.0" fitWidth="16.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../images/question-frame.png" />
</image>
</ImageView>

View File

@ -28,12 +28,21 @@ import javafx.beans.Observable;
import javafx.beans.property.DoubleProperty; import javafx.beans.property.DoubleProperty;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.geometry.Insets;
import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.control.ComboBox; import javafx.scene.control.ComboBox;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.MenuItem; 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 javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Pane;
import javafx.scene.text.Text;
import org.controlsfx.control.PopOver;
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;
@ -56,6 +65,9 @@ public class Toolbar extends ToolBar {
private static final int SIZE_SLIDER_DEFAULT = 100; private static final int SIZE_SLIDER_DEFAULT = 100;
@FXML
private ImageView sortHelpImageView;
@FXML @FXML
private ComboBox<DrawableAttribute<?>> groupByBox; private ComboBox<DrawableAttribute<?>> groupByBox;
@ -104,7 +116,9 @@ public class Toolbar extends ToolBar {
"Toolbar.descRadio=Descending", "Toolbar.descRadio=Descending",
"Toolbar.tagImageViewLabel=Tag Group's Files:", "Toolbar.tagImageViewLabel=Tag Group's Files:",
"Toolbar.categoryImageViewLabel=Categorize Group's Files:", "Toolbar.categoryImageViewLabel=Categorize Group's Files:",
"Toolbar.thumbnailSizeLabel=Thumbnail Size (px):"}) "Toolbar.thumbnailSizeLabel=Thumbnail Size (px):",
"Toolbar.sortHelp=The sort direction (ascending/descending) affects the queue of unseen groups that Image Gallery maintains, but changes to this queue aren't apparent until the \"Next Unseen Group\" button is pressed.",
"Toolbar.sortHelpTitle=Group Sorting",})
void initialize() { void initialize() {
assert catGroupMenuButton != null : "fx:id=\"catSelectedMenubutton\" was not injected: check your FXML file 'Toolbar.fxml'."; assert catGroupMenuButton != null : "fx:id=\"catSelectedMenubutton\" 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 groupByBox != null : "fx:id=\"groupByBox\" was not injected: check your FXML file 'Toolbar.fxml'.";
@ -169,7 +183,43 @@ public class Toolbar extends ToolBar {
sortChooser.sortOrderProperty().addListener(queryInvalidationListener); sortChooser.sortOrderProperty().addListener(queryInvalidationListener);
sortChooser.setComparator(GroupSortBy.PRIORITY); sortChooser.setComparator(GroupSortBy.PRIORITY);
getItems().add(1, sortChooser); getItems().add(1, sortChooser);
sortHelpImageView.setCursor(Cursor.HAND);
sortHelpImageView.setOnMouseClicked(clicked -> {
Text text = new Text(Bundle.Toolbar_sortHelp());
text.setWrappingWidth(480); //This is a hack to fix the layout.
showPopoverHelp(sortHelpImageView,
Bundle.Toolbar_sortHelpTitle(),
sortHelpImageView.getImage(), text);
});
}
/**
*
* Static utility to to show a Popover with the given Node as owner.
*
* @param owner The owner of the Popover
* @param headerText A short String that will be shown in the top-left
* corner of the Popover.
* @param headerImage An Image that will be shown at the top-right corner of
* the Popover.
* @param content The main content of the Popover, shown in the
* bottom-center
*
*/
private static void showPopoverHelp(final Node owner, final String headerText, final Image headerImage, final Node content) {
Pane borderPane = new BorderPane(null, null, new ImageView(headerImage),
content,
new Label(headerText));
borderPane.setPadding(new Insets(10));
borderPane.setPrefWidth(500);
PopOver popOver = new PopOver(borderPane);
popOver.setDetachable(false);
popOver.setArrowLocation(PopOver.ArrowLocation.TOP_CENTER);
popOver.show(owner);
} }
private void syncGroupControlsEnabledState(GroupViewState newViewState) { private void syncGroupControlsEnabledState(GroupViewState newViewState) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 924 B