All Projects → Oliver-Loeffler → FXFileChooser

Oliver-Loeffler / FXFileChooser

Licence: Apache-2.0 License
Custom JavaFX file chooser which allows quick manual filtering, which allows to add Path predicates as filter and which is testable using TestFX.

Programming Languages

java
68154 projects - #9 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to FXFileChooser

lib-preferences
Lib-Preferences is a library for easy storing simple data to a Preferences.properties file in a Java(FX) & Maven desktop application.
Stars: ✭ 12 (-45.45%)
Mutual labels:  javafx, file
adapster
Android library designed to enrich and make your RecyclerView adapters more SOLID
Stars: ✭ 17 (-22.73%)
Mutual labels:  listview
bluebub
A library for creating chat bubbles in JavaFX
Stars: ✭ 43 (+95.45%)
Mutual labels:  javafx
tmpfile
Alternative to tmpfile() function
Stars: ✭ 22 (+0%)
Mutual labels:  file
ShareX-CDN
Basic image, text & file uploader CDN for ShareX
Stars: ✭ 22 (+0%)
Mutual labels:  file
TinyClip
🚀 JavaFX开发的FFMPEG-GUI客户端
Stars: ✭ 59 (+168.18%)
Mutual labels:  javafx
react-native-nlist
原生Listview Native lListView react-native encapsulation Memory recovery reusing High performance
Stars: ✭ 60 (+172.73%)
Mutual labels:  listview
SporeModder-FX
The most advanced and modern Spore modding tool.
Stars: ✭ 24 (+9.09%)
Mutual labels:  javafx
Mime
.NET wrapper for libmagic
Stars: ✭ 51 (+131.82%)
Mutual labels:  file
recyclerview-list-drag-and-drop
No description or website provided.
Stars: ✭ 50 (+127.27%)
Mutual labels:  listview
Code2HTML
JavaFX tool for converting source code to styled HTML
Stars: ✭ 26 (+18.18%)
Mutual labels:  javafx
react-native-swipe-list
Swipeable FlatList Component for react-native
Stars: ✭ 22 (+0%)
Mutual labels:  listview
fs-utils
Generalized file and path utils for Node.js projects.
Stars: ✭ 33 (+50%)
Mutual labels:  file
HXCFE file selector
HxC Floppy Emulator file selector
Stars: ✭ 27 (+22.73%)
Mutual labels:  file
iliasDownloaderTool
synchronize, manage and download the files from your e-learning platform https://www.ilias.de/
Stars: ✭ 46 (+109.09%)
Mutual labels:  javafx
jmonet
An easy-to-use toolkit for incorporating MacPaint / Microsoft Paint-like tools into a Java Swing or JavaFX application.
Stars: ✭ 27 (+22.73%)
Mutual labels:  javafx
EncrypC
🔑 File Encryption Application using Python.
Stars: ✭ 14 (-36.36%)
Mutual labels:  file
msgbots
Messenger Bot Simulator ( Rhino )
Stars: ✭ 17 (-22.73%)
Mutual labels:  javafx
hacklympics
🏆 Full-stack online programming examination system
Stars: ✭ 44 (+100%)
Mutual labels:  javafx
guess-filename.py
Derive a file name according to old file name cues and/or PDF file content
Stars: ✭ 27 (+22.73%)
Mutual labels:  file

FXFileChooser

License javadoc Quality Gate Status codecov Maven Central

Custom JavaFX file chooser which allows quick manual filtering, which allows to add Path predicates as filter and which is testable using TestFX.

As the standard JavaFX file chooser uses system dialogs, so it is hard to test and it is not easy to modifiy (e. g. new Skin). In some cases the system controls even show poor performance opening folders with many files (depends on operating system and JRE version).

On Microsoft Windows platforms running with Java 8, I've encountered cases where it was impossible to use the Java Swing JFileChooser, simply due to the high number of files in a directory. Using the JavaFX FileChooser was also not an option as I required a simplistic way to filter the files by name.

Licensing and attributions

See LICENSE and NOTICE for details. The project is licensed using the Apache License, Version 2.0 and attributes to FontAwesome Free 5.01 (Font Awesome Free License and CC BY 4.0 license).

Adding FXFileChooser to your Maven or Gradle project

Dependency for Maven POM.xml

<dependency>
  <groupId>net.raumzeitfalle.fx</groupId>
  <artifactId>filechooser</artifactId>
  <version>0.0.8</version>
</dependency>

Dependency for Gradle build.gradle

implementation 'net.raumzeitfalle.fx:filechooser:0.0.8'

How it works

FXFileChooser provides access to a DirectoryChooser and a ListView populated with files in the selected directory. The process starts in the users home directory. The ListView is populated by a background service running an update task upon request.

Once the ListView is populated with Path items, those are filtered by the String entered in the filter TextField. The filter condition is "contains" whereas special characters such as '"','?','<','>','|',':','*' are removed.

It turned out that with slow network connections the experience is great when using a single stream and updating the ListView in the streams forEach method. However, this can still take some seconds.

Ideas

  1. Provide some kind of directory content pre fetching for large network shares.
  2. Indicate update progress and update ListView with one operation (one single update works fine, in case of using pre fetching that would be okay). Otherwise one would see an empty List and would have to wait.
  3. In the above case, ensure that files which are selected but do not exist are removed from view on selection or hover OR dont accept the OK action in case the file does no longer exist and trigger update then.
  4. Update the view in one step (one single update works fine, in case of using pre fetching that would be okay). But then also update only what has changed. Never clear the list, only remove items which do no longer exist and add items which are not in the view.
  5. Keep the selection (if file still exists after update)

Available versions

  • FileChooser placed in a customized JavaFX stage
  • One placed in a JavaFX dialog
  • One placed in a JFXPanel so it can be used in Java Swing applications.

Features & Ideas

  • FXFileChooser is based on FXML and CSS and so fully customizable (the ListView might be replaced by a TableView to have more options in terms of sorting - or it will be completely exchangeable - I'll see)
  • Icons are realized as SVGPaths based upon FontAwesome Free 5 (no glyphs, no extra dependencies, the SVGPaths are part of the FXML)
  • The choose directory button provides a menu, where default locations (or a history of locations) can be provided. (tbd.)
  • File types can be selected from filters (tbd.)

default locations path filter search option

  • add sorting by name or time
  • consider using a TableView instead a plain list
  • consider regular expression support for filtering

Ideas

Tests are missing and currently I'm playing with TestFX - but it's not yet working as I like it.

Using the FileChooser with Swing

public class SwingDemo {
    public static void main(String ... args) {

        JFrame frame = new JFrame("Window");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JButton showDialogButton = new JButton("show SwingFileChooser");
        frame.getContentPane().add(showDialogButton);

        SwingFileChooser fileChooser = SwingFileChooser.create(Skin.DARK);

        showDialogButton.addActionListener(l -> {
            int option = fileChooser.showOpenDialog(frame);
            if (option == SwingFileChooser.APPROVE_OPTION) {
                JOptionPane.showMessageDialog(frame, fileChooser.getSelectedFile().toString());
            }
        });

        frame.pack();
        frame.setVisible(true);
    }
}

Swing version with Filter

Using the JavaFX Dialog version

public class FxDialogDemo extends Application  {
    public static void main(String[] args) {
        Application.launch();
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        Button button = new Button("Show File Chooser Dialog");
        FXFileChooserDialog dialog = FXFileChooserDialog.create(Skin.DARK);
        button.setOnAction(evt-> dialog.showOpenDialog(primaryStage).ifPresent(this::showSelection));

        Scene scene = new Scene(button);
        primaryStage.setScene(scene);
        primaryStage.setTitle("Demo");
        primaryStage.show();
    }

    private void showSelection(Path selectedPath) {
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setHeaderText("File Selection");
        alert.setContentText(selectedPath.toString());
        alert.show();
    }
}

Swing version with Filter

A version with a completely customizable stage

public class FxStageDemo extends Application  {
    public static void main(String[] args) {
        Application.launch();
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        Button button = new Button("Show File Chooser Stage");
        FXFileChooserStage fc = FXFileChooserStage.create(Skin.DARK);
        button.setOnAction(evt-> fc.showOpenDialog(primaryStage).ifPresent(this::showSelection));

        Scene scene = new Scene(button);
        primaryStage.setScene(scene);
        primaryStage.setTitle("Demo");
        primaryStage.show();
    }

    private void showSelection(Path selectedPath) {
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setHeaderText("File Selection");
        alert.setContentText(selectedPath.toString());
        alert.show();
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].