Skip to content

Commit

Permalink
Simplify selection mode use on JfxFilePicker implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
besidev committed Oct 17, 2023
1 parent 94649c7 commit 9019d7e
Showing 1 changed file with 2 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
public final class JfxFilePicker extends BaseFilePicker<NativeFileSource> {

private final FileChooser fileChooser = new FileChooser();
private boolean multiple = false;
private List<NativeFileSource> nativeFileSources = List.of();
private final ListChangeListener<ExtensionFilter> extensionListFiltersListener = change -> {
while (change.next()) {
Expand Down Expand Up @@ -62,7 +61,7 @@ public JfxFilePicker(Node node) {
// Define the action that should be performed when the user clicks on the node.
node.setOnMouseClicked(mouseEvent -> {
Window window = node.getScene().getWindow();
if (multiple) {
if (getSelectionMode() == SelectionMode.MULTIPLE) {
final List<File> files = fileChooser.showOpenMultipleDialog(window);
if (files != null && !files.isEmpty()) {
// Create a list of native file sources from the selected files.
Expand Down Expand Up @@ -154,14 +153,7 @@ protected void invalidated() {
@Override
public ObjectProperty<SelectionMode> selectionModeProperty() {
if (selectionMode == null) {
selectionMode = new SimpleObjectProperty<>(this, "selectionMode", SelectionMode.SINGLE) {

@Override
protected void invalidated() {
final SelectionMode selectionMode = get();
multiple = selectionMode == SelectionMode.MULTIPLE;
}
};
selectionMode = new SimpleObjectProperty<>(this, "selectionMode", SelectionMode.SINGLE);
}
return selectionMode;
}
Expand Down

0 comments on commit 9019d7e

Please sign in to comment.