Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/matcher/gui/Gui.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.concurrent.Executors;
import java.util.function.Consumer;
import java.util.function.DoubleConsumer;
import java.util.stream.Collectors;

import javafx.application.Application;
import javafx.application.Platform;
Expand Down Expand Up @@ -306,6 +307,20 @@ public static Path requestFile(String title, Window parent, List<ExtensionFilter
return file.toPath();
}

public static List<Path> requestFiles(String title, Window parent, List<ExtensionFilter> extensionFilters) {
FileChooser fileChooser = new FileChooser();

fileChooser.setTitle(title);
fileChooser.getExtensionFilters().addAll(extensionFilters);
if (lastChooserFile != null) fileChooser.setInitialDirectory(lastChooserFile);

List<File> files = fileChooser.showOpenMultipleDialog(parent);

if (!files.isEmpty()) lastChooserFile = files.get(0).getParentFile();

return files.stream().map(File::toPath).collect(Collectors.toList());
}

public static Path requestDir(String title, Window parent) {
DirectoryChooser fileChooser = new DirectoryChooser();

Expand Down
10 changes: 6 additions & 4 deletions src/matcher/gui/menu/NewProjectPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,12 @@ private Node createFilesSelectionPane(String name, ObservableList<Path> entries,

Button button = new Button("add");
footer.getChildren().add(button);
button.setOnAction(event -> {
Path path = Gui.requestFile("Select file to add", window, getInputLoadExtensionFilters(), true);
if (path != null && !list.getItems().contains(path)) list.getItems().add(path);
});
button.setOnAction(event ->
Gui.requestFiles("Select files to add", window, getInputLoadExtensionFilters())
.stream()
.filter(path -> !list.getItems().contains(path))
.forEach(path -> list.getItems().add(path))
);

Button removeButton = new Button("remove");
footer.getChildren().add(removeButton);
Expand Down