├── .editorconfig
├── .github
└── workflows
│ ├── verify-linux.yml
│ └── verify-windows.yml
├── .gitignore
├── .mvn
└── wrapper
│ ├── MavenWrapperDownloader.java
│ └── maven-wrapper.properties
├── LICENSE
├── NOTICE
├── README.md
├── _config.yml
├── checkstyle.xml
├── demos
├── TestData
│ └── SomeFiles
│ │ ├── HorrbibleSpreadSheet.xls
│ │ ├── JustNumbers.csv
│ │ ├── NewerDocument.docx
│ │ ├── OldDocument.doc
│ │ ├── SupposedToBeXtensible.xml
│ │ ├── TestFile1.txt
│ │ ├── TestFile2.txt
│ │ ├── TestFile3.txt
│ │ ├── TestFile4.txt
│ │ ├── TestFile5.txt
│ │ ├── XtremeHorrbibleSpreadSheet.xlsx
│ │ └── anotherDir
│ │ └── TestFile2.txt
├── pom.xml
└── src
│ └── main
│ ├── java
│ ├── module-info.java
│ └── net
│ │ └── raumzeitfalle
│ │ └── demos
│ │ ├── DemoDirectoryChooser.java
│ │ ├── DemoFileChooser.java
│ │ ├── DemoFxDialog.java
│ │ ├── DemoFxStage.java
│ │ ├── DemoJavaFxDialog.java
│ │ ├── DemoJavaFxStage.java
│ │ ├── DemoJavaSwingIntegration.java
│ │ ├── DemoSwing.java
│ │ └── fxml
│ │ ├── ApplicationTemplate.java
│ │ ├── Demo1.java
│ │ ├── Demo2.java
│ │ ├── Demo3.java
│ │ ├── DemoApplication.java
│ │ └── DemoController.java
│ └── resources
│ ├── FXMLView.fxml
│ └── net
│ └── raumzeitfalle
│ └── demos
│ └── fxml
│ ├── Demo1.fxml
│ ├── Demo2.fxml
│ └── Demo3.fxml
├── eclipse-java-code-formatter-settings.xml
├── filechooser
├── pom.xml
└── src
│ └── main
│ ├── java
│ ├── module-info.java
│ └── net
│ │ └── raumzeitfalle
│ │ └── fx
│ │ ├── dirchooser
│ │ ├── DirectoryChooser.java
│ │ ├── DirectoryChooserController.java
│ │ ├── DirectoryChooserProperties.java
│ │ ├── DirectoryChooserView.java
│ │ ├── DirectoryIcons.java
│ │ ├── DirectoryTreeItem.java
│ │ ├── DirectoryTreeUpdateTask.java
│ │ ├── DirectoryWalker.java
│ │ └── ProgressIcon.java
│ │ └── filechooser
│ │ ├── DirectoryChooserOption.java
│ │ ├── FXDirectoryChooser.java
│ │ ├── FXFileChooserDialog.java
│ │ ├── FXFileChooserStage.java
│ │ ├── FileChooser.java
│ │ ├── FileChooserController.java
│ │ ├── FileChooserModel.java
│ │ ├── FileChooserProperties.java
│ │ ├── FileChooserViewOption.java
│ │ ├── FileIcons.java
│ │ ├── FileUpdateService.java
│ │ ├── FilesListCell.java
│ │ ├── FindFilesTask.java
│ │ ├── HideableView.java
│ │ ├── IndexedPath.java
│ │ ├── Invoke.java
│ │ ├── LocationMenuItemFactory.java
│ │ ├── PathComparator.java
│ │ ├── PathFilter.java
│ │ ├── PathUpdateHandler.java
│ │ ├── RefreshBuffer.java
│ │ ├── Skin.java
│ │ ├── SwingDialogReturnValues.java
│ │ ├── SwingFileChooser.java
│ │ ├── SwingFileChooserProperties.java
│ │ ├── UpdateService.java
│ │ └── locations
│ │ ├── Location.java
│ │ ├── Locations.java
│ │ └── NamedLocation.java
│ └── resources
│ ├── directorychooser.properties
│ ├── filechooser.properties
│ ├── net
│ └── raumzeitfalle
│ │ └── fx
│ │ ├── dirchooser
│ │ ├── DirectoryChooser.fxml
│ │ ├── DirectoryChooserDark.css
│ │ ├── DirectoryChooserView.fxml
│ │ ├── DirectoryChooserViewDark.css
│ │ ├── fireworks
│ │ │ ├── folder-closed-32.fw.png
│ │ │ ├── folder-closed-plus-32.fw.png
│ │ │ ├── folder-closed-unknown-xl-32.fw.png
│ │ │ ├── folder-closed-xl-32.fw.png
│ │ │ ├── folder-empty-32.fw.png
│ │ │ ├── folder-file-open-32.fw.png
│ │ │ ├── folder-open-32.fw.png
│ │ │ ├── host-computer-32.fw.png
│ │ │ ├── windows-drive-32.fw.png
│ │ │ ├── windows-drive-empty-32.fw.png
│ │ │ ├── windows-drive-plus-32.fw.png
│ │ │ └── windows-drive-xl-32.fw.png
│ │ └── icons
│ │ │ ├── folder-closed-32.png
│ │ │ ├── folder-closed-plus-32.png
│ │ │ ├── folder-closed-unknown-xl-32.png
│ │ │ ├── folder-closed-xl-32.png
│ │ │ ├── folder-empty-32.png
│ │ │ ├── folder-file-open-32.png
│ │ │ ├── folder-open-32.png
│ │ │ ├── host-computer-32.png
│ │ │ ├── windows-drive-32.png
│ │ │ ├── windows-drive-empty-32.png
│ │ │ ├── windows-drive-plus-32.png
│ │ │ └── windows-drive-xl-32.png
│ │ └── filechooser
│ │ ├── FXFileChooserDialogDark.css
│ │ ├── FileChooser.fxml
│ │ ├── FileChooserDark.css
│ │ ├── FileChooserModena.css
│ │ ├── FileChooserView.fxml
│ │ ├── FileChooserViewDark.css
│ │ ├── copy-solid.svg
│ │ ├── file-alt.svg
│ │ ├── filter.svg
│ │ ├── fireworks
│ │ ├── file-csv.fw.png
│ │ ├── file-doc.fw.png
│ │ ├── file-docx.fw.png
│ │ ├── file-docx2.fw.png
│ │ ├── file-docx3.fw.png
│ │ ├── file-docx4.fw.png
│ │ ├── file-icon-template.fw.png
│ │ ├── file-template.png
│ │ ├── file-txt.fw.png
│ │ ├── file-xls.fw.png
│ │ ├── file-xlsx.fw.png
│ │ ├── file-xlsx3.fw.png
│ │ ├── file-xlsx4.fw.png
│ │ ├── file-xml.fw.png
│ │ └── template.png
│ │ ├── folder-open.svg
│ │ ├── icons
│ │ ├── file-csv.png
│ │ ├── file-doc.png
│ │ ├── file-docx.png
│ │ ├── file-docx2.png
│ │ ├── file-docx3.png
│ │ ├── file-docx4.png
│ │ ├── file-txt.png
│ │ ├── file-unknown.png
│ │ ├── file-xls.png
│ │ ├── file-xlsx.png
│ │ ├── file-xlsx3.png
│ │ ├── file-xlsx4.png
│ │ └── file-xml.png
│ │ ├── paste-solid.svg
│ │ ├── sort-alpha-down.svg
│ │ ├── sort-alpha-up.svg
│ │ ├── sort-calendar-down.svg
│ │ ├── sort-calendar-up.svg
│ │ ├── sort-time-down.svg
│ │ ├── sort-time-up.svg
│ │ ├── stop-circle.svg
│ │ ├── stop.svg
│ │ └── sync-alt.svg
│ └── swingfilechooser.properties
├── mvnw
├── mvnw.cmd
├── pages
├── ConvenienceFunctions.png
├── DefaultLocationsExample.png
├── OSX_JavaFX_Dialog.png
├── OSX_JavaFX_Stage.png
├── OSX_Swing_JFXPanel.png
├── PathFilterExample.png
├── SortingMenuExample.png
├── Windows81_JavaFX_Stage.png
├── Windows81_Swing_Dialog_ProcessRunning.png
└── filechooser
│ ├── FXML_and_ids.afdesign
│ └── FXML_and_ids.png
├── pom.xml
├── scenicView.properties
└── tests
├── TestData
└── SomeFiles
│ ├── HorrbibleSpreadSheet.xls
│ ├── JustNumbers.csv
│ ├── NewerDocument.docx
│ ├── OldDocument.doc
│ ├── SupposedToBeXtensible.xml
│ ├── TestFile1.txt
│ ├── TestFile2.txt
│ ├── TestFile3.txt
│ ├── TestFile4.txt
│ ├── TestFile5.txt
│ ├── XtremeHorrbibleSpreadSheet.xlsx
│ └── anotherDir
│ └── TestFile2.txt
├── pom.xml
└── src
└── test
└── java
└── net
└── raumzeitfalle
└── fx
└── filechooser
├── FXFileChooserStage1Test.java
├── FXFileChooserStage2Test.java
├── FXFileChooserStage3Test.java
├── FileChooserControllerTest.java
├── FileChooserDarkTest.java
├── FileChooserModelApplicationTest.java
├── FileChooserModelFactoryMethodsFxTest.java
├── FileChooserModelTest.java
├── FileChooserModenaTest.java
├── FileChooserTestBase.java
├── FileUpdateServiceTest.java
├── FilesListCellTest.java
├── FindFilesTaskTest.java
├── FxTestTemplate.java
├── IndexedPathTest.java
├── PathComparatorTest.java
├── PathFilterTest.java
├── RandomFileCreator.java
├── RefreshBufferTest.java
├── ServiceWorkerStateListener.java
└── locations
├── LocationsTest.java
└── NamedLocationTest.java
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig is awesome: https://EditorConfig.org
2 | root = true
3 |
4 | [*.java]
5 | indent_style = space
6 | indent_size = 4
7 |
8 | [*.fxml]
9 | indent_style = space
10 | indent_size = 2
11 |
12 | [*.yml]
13 | indent_style = space
14 | indent_size = 2
15 |
16 | [pom.xml]
17 | indent_style = space
18 | indent_size = 4
19 |
--------------------------------------------------------------------------------
/.github/workflows/verify-linux.yml:
--------------------------------------------------------------------------------
1 | # This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
3 |
4 | # This workflow uses actions that are not certified by GitHub.
5 | # They are provided by a third-party and are governed by
6 | # separate terms of service, privacy policy, and support
7 | # documentation.
8 |
9 | name: Verify on Linux Ubuntu
10 |
11 | on: workflow_dispatch
12 |
13 | jobs:
14 | build:
15 | runs-on: ubuntu-latest
16 | steps:
17 | - uses: actions/checkout@v3
18 | - name: Set up JDK 17
19 | uses: actions/setup-java@v3
20 | with:
21 | java-version: '17'
22 | distribution: 'zulu'
23 | cache: maven
24 | - name: Setup
25 | run: export DISPLAY=:90 & Xvfb -ac :90 -screen 0 1280x1024x24 > /dev/null 2>&1
26 | - name: Verify
27 | run: mvn -B verify -P github
28 |
--------------------------------------------------------------------------------
/.github/workflows/verify-windows.yml:
--------------------------------------------------------------------------------
1 | # This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
3 |
4 | # This workflow uses actions that are not certified by GitHub.
5 | # They are provided by a third-party and are governed by
6 | # separate terms of service, privacy policy, and support
7 | # documentation.
8 |
9 | name: Verify on Windows
10 |
11 | on: push
12 |
13 | jobs:
14 | build:
15 |
16 | runs-on: windows-latest
17 |
18 | steps:
19 | - uses: actions/checkout@v3
20 | - name: Set up JDK 17
21 | uses: actions/setup-java@v3
22 | with:
23 | java-version: '17'
24 | distribution: 'zulu'
25 | cache: maven
26 | - name: Verify
27 | run: mvn -B verify -P github
28 |
29 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .classpath
2 | .DS_Store
3 | Screenshot*.png
4 | .flattened-pom.xml
5 | .idea/
6 | .mvn/wrapper/maven-wrapper.jar
7 | .project
8 | .project/
9 | .settings/
10 | filechooser.iml
11 | target/
12 | build/
13 | bin/
14 |
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
3 |
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 | Copyright (C) 2017 - 2019 Oliver Loeffler, Raumzeitfalle.net
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | 1. Open Source Attributions
16 |
17 | The icon shapes (SVG) used herein are provided by FontAwesome Free 5.01.
18 | FontAwesome Free 5.01 is licensed under Font Awesome Free License.
19 |
20 | In the Font Awesome Free download, the CC BY 4.0 license applies to all icons
21 | packaged as SVG and JS file types.
22 |
23 | In most cases, the SVG files are not used directly but the included SVG paths
24 | and shapes are embedded into either FXML code or JAVA code.
25 |
26 | 1.1 Font Awesome Free License
27 | https://fontawesome.com/license/free
28 |
29 | 1.2 CC BY 4.0 license
30 | https://creativecommons.org/licenses/by/4.0/
31 |
32 | 2. Modifications
33 |
34 | The SVG icons provided by FontAwesome Free have been modified using
35 | InkScape https://inkscape.org/. Modifications include (but are not limited to)
36 | aspect ratio and size of the SVG files.
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-cayman
--------------------------------------------------------------------------------
/checkstyle.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/demos/TestData/SomeFiles/HorrbibleSpreadSheet.xls:
--------------------------------------------------------------------------------
1 | TestFile1.txt
--------------------------------------------------------------------------------
/demos/TestData/SomeFiles/JustNumbers.csv:
--------------------------------------------------------------------------------
1 | TestFile1.txt
--------------------------------------------------------------------------------
/demos/TestData/SomeFiles/NewerDocument.docx:
--------------------------------------------------------------------------------
1 | TestFile1.txt
--------------------------------------------------------------------------------
/demos/TestData/SomeFiles/OldDocument.doc:
--------------------------------------------------------------------------------
1 | TestFile1.txt
--------------------------------------------------------------------------------
/demos/TestData/SomeFiles/SupposedToBeXtensible.xml:
--------------------------------------------------------------------------------
1 | TestFile1.txt
--------------------------------------------------------------------------------
/demos/TestData/SomeFiles/TestFile1.txt:
--------------------------------------------------------------------------------
1 | TestFile1.txt
--------------------------------------------------------------------------------
/demos/TestData/SomeFiles/TestFile2.txt:
--------------------------------------------------------------------------------
1 | TestFile2.txt
--------------------------------------------------------------------------------
/demos/TestData/SomeFiles/TestFile3.txt:
--------------------------------------------------------------------------------
1 | TestFile3.txt
--------------------------------------------------------------------------------
/demos/TestData/SomeFiles/TestFile4.txt:
--------------------------------------------------------------------------------
1 | TestFile4.txt
--------------------------------------------------------------------------------
/demos/TestData/SomeFiles/TestFile5.txt:
--------------------------------------------------------------------------------
1 | TestFile5.txt
--------------------------------------------------------------------------------
/demos/TestData/SomeFiles/XtremeHorrbibleSpreadSheet.xlsx:
--------------------------------------------------------------------------------
1 | TestFile1.txt
--------------------------------------------------------------------------------
/demos/TestData/SomeFiles/anotherDir/TestFile2.txt:
--------------------------------------------------------------------------------
1 | TestFile2.txt
--------------------------------------------------------------------------------
/demos/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | net.raumzeitfalle.fx
6 | fxfilechooser
7 | 0.0.12-SNAPSHOT
8 |
9 | 4.0.0
10 | demos
11 | jar
12 |
13 |
14 |
15 | net.raumzeitfalle.fx
16 | filechooser
17 | 0.0.12-SNAPSHOT
18 |
19 |
20 |
21 |
22 |
23 |
24 | org.apache.maven.plugins
25 | maven-compiler-plugin
26 |
27 | ${java.version}
28 | ${java.version}
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/demos/src/main/java/module-info.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2022 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 |
21 | module net.raumzeitfalle.demos {
22 | requires java.logging;
23 | requires javafx.controls;
24 | requires javafx.swing;
25 | requires transitive java.desktop;
26 | requires transitive javafx.graphics;
27 | requires transitive javafx.fxml;
28 | requires net.raumzeitfalle.fxfilechooser;
29 | opens net.raumzeitfalle.demos to javafx.fxml, javafx.graphics;
30 | opens net.raumzeitfalle.demos.fxml to javafx.fxml, javafx.graphics;
31 | }
32 |
--------------------------------------------------------------------------------
/demos/src/main/java/net/raumzeitfalle/demos/DemoDirectoryChooser.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2022 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.demos;
21 |
22 | import java.nio.file.Path;
23 |
24 | import javafx.application.Application;
25 | import javafx.scene.Scene;
26 | import javafx.scene.control.Alert;
27 | import javafx.stage.Stage;
28 | import net.raumzeitfalle.fx.dirchooser.DirectoryChooser;
29 | import net.raumzeitfalle.fx.filechooser.Skin;
30 |
31 | public class DemoDirectoryChooser extends Application {
32 | public static void main(String[] args) {
33 | Application.launch();
34 | }
35 |
36 | private DirectoryChooser dirChooser;
37 |
38 | private Scene scene;
39 |
40 | @Override
41 | public void start(Stage primaryStage) throws Exception {
42 | dirChooser = new DirectoryChooser(Skin.DARK);
43 | dirChooser.useCancelButtonProperty().setValue(true);
44 | dirChooser.onSelect(() -> {
45 | Path selectedDir = dirChooser.selectedDirectoryProperty().get();
46 | showMessage("Selected:", selectedDir.normalize().toAbsolutePath().toString());
47 | });
48 | dirChooser.onCancel(() ->
49 | showMessage("Cancelled:", "One can hide the cancel button if not needed.")
50 | );
51 | scene = new Scene(dirChooser);
52 | primaryStage.setScene(scene);
53 | primaryStage.setTitle("Demo");
54 | primaryStage.show();
55 | }
56 |
57 | @Override
58 | public void stop() {
59 | dirChooser.shutdown();
60 | }
61 |
62 | private void showMessage(String action, String message) {
63 | Alert alert = new Alert(Alert.AlertType.INFORMATION);
64 | alert.initOwner(scene.getWindow());
65 | alert.setTitle("DirectoryChooser");
66 | alert.setHeaderText(action);
67 | alert.setContentText(message);
68 | alert.show();
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/demos/src/main/java/net/raumzeitfalle/demos/DemoFileChooser.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2022 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.demos;
21 |
22 | import javafx.application.Application;
23 | import javafx.scene.Scene;
24 | import javafx.stage.Stage;
25 | import net.raumzeitfalle.fx.filechooser.DirectoryChooserOption;
26 | import net.raumzeitfalle.fx.filechooser.FileChooser;
27 | import net.raumzeitfalle.fx.filechooser.Skin;
28 |
29 | public class DemoFileChooser extends Application {
30 |
31 | public static void main(String[] args) {
32 | Application.launch();
33 | }
34 |
35 | private FileChooser fileChooser;
36 |
37 | @Override
38 | public void start(Stage primaryStage) throws Exception {
39 | fileChooser = new FileChooser(Skin.DARK, DirectoryChooserOption.CUSTOM);
40 | Scene scene = new Scene(fileChooser);
41 | primaryStage.setScene(scene);
42 | primaryStage.setTitle("Demo");
43 | primaryStage.show();
44 | }
45 |
46 | @Override
47 | public void stop() {
48 | fileChooser.shutdown();
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/demos/src/main/java/net/raumzeitfalle/demos/DemoFxDialog.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2020 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.demos;
21 |
22 | import java.nio.file.Path;
23 |
24 | import javafx.application.Application;
25 | import javafx.scene.Scene;
26 | import javafx.scene.control.Alert;
27 | import javafx.scene.control.Button;
28 | import javafx.stage.Stage;
29 | import net.raumzeitfalle.fx.filechooser.FXFileChooserDialog;
30 | import net.raumzeitfalle.fx.filechooser.Skin;
31 |
32 | public class DemoFxDialog extends Application {
33 | public static void main(String[] args) {
34 | Application.launch();
35 | }
36 |
37 | @Override
38 | public void start(Stage primaryStage) throws Exception {
39 | Button button = new Button("Show File Chooser");
40 | FXFileChooserDialog dialog = FXFileChooserDialog.create(Skin.DARK);
41 | button.setOnAction(evt -> dialog.showOpenDialog(primaryStage).ifPresent(this::showSelection));
42 |
43 | Scene scene = new Scene(button);
44 | primaryStage.setScene(scene);
45 | primaryStage.setTitle("Demo");
46 | primaryStage.show();
47 | }
48 |
49 | private void showSelection(Path selectedPath) {
50 | Alert alert = new Alert(Alert.AlertType.INFORMATION);
51 | alert.setHeaderText("File Selection");
52 | alert.setContentText(selectedPath.toString());
53 | alert.show();
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/demos/src/main/java/net/raumzeitfalle/demos/DemoFxStage.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2020 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.demos;
21 |
22 | import javafx.application.Application;
23 | import javafx.scene.Scene;
24 | import javafx.scene.control.Alert;
25 | import javafx.scene.control.Button;
26 | import javafx.stage.Stage;
27 | import net.raumzeitfalle.fx.filechooser.FXFileChooserStage;
28 | import net.raumzeitfalle.fx.filechooser.Skin;
29 |
30 | import java.nio.file.Path;
31 |
32 | public class DemoFxStage extends Application {
33 | public static void main(String[] args) {
34 | Application.launch();
35 | }
36 |
37 | @Override
38 | public void start(Stage primaryStage) throws Exception {
39 | Button button = new Button("Show File Chooser");
40 | FXFileChooserStage fc = FXFileChooserStage.create(Skin.DARK);
41 | button.setOnAction(evt -> fc.showOpenDialog(primaryStage)
42 | .ifPresent(this::showSelection));
43 |
44 | Scene scene = new Scene(button);
45 | primaryStage.setScene(scene);
46 | primaryStage.setTitle("Demo");
47 | primaryStage.show();
48 | }
49 |
50 | private void showSelection(Path selectedPath) {
51 | Alert alert = new Alert(Alert.AlertType.INFORMATION);
52 | alert.setHeaderText("File Selection");
53 | alert.setContentText(selectedPath.toString());
54 | alert.show();
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/demos/src/main/java/net/raumzeitfalle/demos/DemoJavaFxDialog.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2019 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.demos;
21 |
22 | import java.nio.file.Path;
23 | import java.nio.file.Paths;
24 | import java.util.ArrayList;
25 | import java.util.List;
26 | import java.util.Optional;
27 | import java.util.logging.Level;
28 | import java.util.logging.Logger;
29 |
30 | import javafx.application.Application;
31 | import javafx.scene.Scene;
32 | import javafx.scene.control.Button;
33 | import javafx.scene.layout.VBox;
34 | import javafx.stage.Stage;
35 | import net.raumzeitfalle.fx.filechooser.FXFileChooserDialog;
36 | import net.raumzeitfalle.fx.filechooser.PathFilter;
37 | import net.raumzeitfalle.fx.filechooser.Skin;
38 | import net.raumzeitfalle.fx.filechooser.locations.Location;
39 | import net.raumzeitfalle.fx.filechooser.locations.Locations;
40 |
41 | public class DemoJavaFxDialog extends Application {
42 |
43 | @Override
44 | public void start(Stage primaryStage) throws Exception {
45 |
46 | PathFilter all = PathFilter.acceptAllFiles("all files");
47 |
48 | PathFilter exe = PathFilter.forFileExtension("Program", "exe");
49 | PathFilter xml = PathFilter.forFileExtension("XML", "xml");
50 | PathFilter txt = PathFilter.forFileExtension("Text", "txt");
51 |
52 | PathFilter xls = PathFilter.forFileExtension("Excel 2003", "xls");
53 | PathFilter xlsx = PathFilter.forFileExtension("Excel 2007+", "xlsx").combine(xls);
54 |
55 | FXFileChooserDialog darkfc = FXFileChooserDialog.create(Skin.DARK, all, exe, xml, txt, xlsx);
56 |
57 | List locations = new ArrayList<>();
58 | locations.add(Locations.withName("Configs: /etc", Paths.get("/etc")));
59 | locations.add(Locations.withName("User Homes: /Users", Paths.get("/Users")));
60 | locations.add(Locations.withName("C-Drive: C:\\", Paths.get("C:/")));
61 |
62 | darkfc.addLocations(locations);
63 |
64 | Logger logger = Logger.getLogger(DemoJavaFxDialog.class.getSimpleName());
65 |
66 | Button showDarkDialog = new Button("Show dark JavaFX Dialog (FXFileChooserDialog.class)");
67 | showDarkDialog.setOnAction(a -> {
68 |
69 | Optional path = darkfc.showOpenDialog(primaryStage);
70 | logger.log(Level.INFO, path.map(String::valueOf).orElse("Nothing selected"));
71 |
72 | });
73 |
74 | FXFileChooserDialog fc = FXFileChooserDialog.create(Skin.MODENA, all, exe, xml, txt, xlsx);
75 | Button showDialog = new Button("Show default JavaFX Dialog (FXFileChooserDialog.class)");
76 | showDialog.setOnAction(a -> {
77 |
78 | Optional path = fc.showOpenDialog(primaryStage);
79 | logger.log(Level.INFO, path.map(String::valueOf).orElse("Nothing selected"));
80 |
81 | });
82 |
83 | VBox vbox = new VBox(showDarkDialog, showDialog);
84 | Scene scene = new Scene(vbox);
85 | primaryStage.setScene(scene);
86 | primaryStage.setWidth(400);
87 | primaryStage.setHeight(200);
88 | primaryStage.show();
89 | }
90 |
91 | public static void main(String[] args) {
92 | launch(new String[0]);
93 | }
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/demos/src/main/java/net/raumzeitfalle/demos/DemoSwing.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2020 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.demos;
21 |
22 | import java.awt.FlowLayout;
23 |
24 | import javax.swing.JButton;
25 | import javax.swing.JFrame;
26 | import javax.swing.JOptionPane;
27 |
28 | import net.raumzeitfalle.fx.filechooser.Skin;
29 | import net.raumzeitfalle.fx.filechooser.SwingFileChooser;
30 |
31 | public class DemoSwing {
32 | public static void main(String... args) {
33 |
34 | JFrame frame = new JFrame("Window");
35 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
36 | frame.setLayout(new FlowLayout(FlowLayout.LEFT));
37 | JButton showDialogButton = new JButton("show SwingFileChooser");
38 | frame.getContentPane().add(showDialogButton);
39 |
40 | // SwingFileChooser.setUseJavaFxDirectoryChooser(true);
41 | SwingFileChooser fileChooser = SwingFileChooser.create(Skin.DARK);
42 | showDialogButton.addActionListener(l -> {
43 | int option = fileChooser.showOpenDialog(frame);
44 | if (option == SwingFileChooser.APPROVE_OPTION) {
45 | JOptionPane.showMessageDialog(frame, fileChooser.getSelectedFile().toString());
46 | }
47 | });
48 |
49 | frame.pack();
50 | frame.setVisible(true);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/demos/src/main/java/net/raumzeitfalle/demos/fxml/ApplicationTemplate.java:
--------------------------------------------------------------------------------
1 | package net.raumzeitfalle.demos.fxml;
2 |
3 | import javafx.application.Application;
4 | import javafx.fxml.FXMLLoader;
5 | import javafx.scene.Scene;
6 | import javafx.scene.layout.Pane;
7 | import javafx.stage.Stage;
8 |
9 | import java.net.URL;
10 |
11 | abstract class ApplicationTemplate extends Application {
12 | @Override
13 | public void start(Stage stage) throws Exception {
14 | FXMLLoader loader = new FXMLLoader();
15 | DemoController controller = new DemoController();
16 | loader.setController(controller);
17 |
18 | String appName = getClass().getSimpleName();
19 | URL fxmlUrl = getClass().getResource(appName+".fxml");
20 | loader.setLocation(fxmlUrl);
21 |
22 | Pane root = loader.load();
23 | Scene scene = new Scene(root);
24 |
25 | stage.setScene(scene);
26 | stage.setTitle(appName+" Application");
27 | stage.show();
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/demos/src/main/java/net/raumzeitfalle/demos/fxml/Demo1.java:
--------------------------------------------------------------------------------
1 | package net.raumzeitfalle.demos.fxml;
2 |
3 | /**
4 | * FXML using constructor arguments
5 | *
7 | */
8 | public class Demo1 extends ApplicationTemplate {
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/demos/src/main/java/net/raumzeitfalle/demos/fxml/Demo2.java:
--------------------------------------------------------------------------------
1 | package net.raumzeitfalle.demos.fxml;
2 |
3 | /**
4 | * FXML using constructor arguments
5 | *
7 | */
8 | public class Demo2 extends ApplicationTemplate {
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/demos/src/main/java/net/raumzeitfalle/demos/fxml/Demo3.java:
--------------------------------------------------------------------------------
1 | package net.raumzeitfalle.demos.fxml;
2 |
3 | /**
4 | * FXML using constructor arguments
5 | *
7 | */
8 | public class Demo3 extends ApplicationTemplate {
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/demos/src/main/java/net/raumzeitfalle/demos/fxml/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package net.raumzeitfalle.demos.fxml;
2 |
3 | import java.net.URL;
4 |
5 | import javafx.application.Application;
6 | import javafx.fxml.FXMLLoader;
7 | import javafx.scene.Scene;
8 | import javafx.scene.layout.Pane;
9 | import javafx.stage.Stage;
10 |
11 | public class DemoApplication extends Application {
12 |
13 | public static void main(String[] args) {
14 | launch(DemoApplication.class);
15 | }
16 |
17 | @Override
18 | public void start(Stage stage) throws Exception {
19 | FXMLLoader loader = new FXMLLoader();
20 | DemoController controller = new DemoController();
21 | loader.setController(controller);
22 |
23 | URL fxmlUrl = getClass().getResource("/FXMLView.fxml");
24 | loader.setLocation(fxmlUrl);
25 |
26 | Pane root = loader.load();
27 | Scene scene = new Scene(root);
28 |
29 | stage.setScene(scene);
30 | stage.setTitle("Demo Application");
31 | stage.show();
32 |
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/demos/src/main/java/net/raumzeitfalle/demos/fxml/DemoController.java:
--------------------------------------------------------------------------------
1 | package net.raumzeitfalle.demos.fxml;
2 |
3 | import java.net.URL;
4 | import java.util.ResourceBundle;
5 |
6 | import javafx.fxml.FXML;
7 | import javafx.fxml.Initializable;
8 | import javafx.scene.control.Button;
9 |
10 | public class DemoController implements Initializable {
11 |
12 | @FXML
13 | public net.raumzeitfalle.fx.filechooser.FileChooser fileChooser;
14 |
15 | @FXML
16 | public Button actionButton;
17 |
18 | @Override
19 | public void initialize(URL url, ResourceBundle resourceBundle) {
20 |
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/demos/src/main/resources/FXMLView.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/demos/src/main/resources/net/raumzeitfalle/demos/fxml/Demo1.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/demos/src/main/resources/net/raumzeitfalle/demos/fxml/Demo2.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/demos/src/main/resources/net/raumzeitfalle/demos/fxml/Demo3.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/module-info.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2022 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 |
21 | module net.raumzeitfalle.fxfilechooser {
22 | requires java.logging;
23 | requires javafx.controls;
24 | requires javafx.swing;
25 |
26 | requires transitive java.desktop;
27 | requires transitive javafx.graphics;
28 | requires transitive javafx.fxml;
29 |
30 | exports net.raumzeitfalle.fx.filechooser;
31 | exports net.raumzeitfalle.fx.filechooser.locations;
32 | exports net.raumzeitfalle.fx.dirchooser;
33 |
34 | opens net.raumzeitfalle.fx.filechooser to javafx.fxml;
35 | opens net.raumzeitfalle.fx.dirchooser to javafx.fxml;
36 | }
37 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/net/raumzeitfalle/fx/dirchooser/DirectoryChooserProperties.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2022 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.dirchooser;
21 |
22 | import java.io.File;
23 | import java.io.FileInputStream;
24 | import java.net.URL;
25 | import java.util.Properties;
26 | import java.util.logging.Level;
27 | import java.util.logging.Logger;
28 |
29 | public enum DirectoryChooserProperties {
30 | INSTANCE;
31 |
32 | static {
33 | INSTANCE.load();
34 | }
35 |
36 | static final String PROPERTIES_FILE = "directorychooser.properties";
37 | static final String PROPERTY_ICON_SIZE = "directory.chooser.icon.size";
38 |
39 | private final Properties properties;
40 |
41 | private DirectoryChooserProperties() {
42 | this.properties = new Properties();
43 | }
44 |
45 | public static int getIconSize() {
46 | return INSTANCE.getIntProperty(PROPERTY_ICON_SIZE, 24);
47 | }
48 |
49 | public static double getIconPaneSize() {
50 | return INSTANCE.getIntProperty(PROPERTY_ICON_SIZE, 24) * 1.5;
51 | }
52 |
53 | public static void setIconSize(int newIconSize) {
54 | INSTANCE.properties
55 | .setProperty(PROPERTY_ICON_SIZE,
56 | Integer.toString(newIconSize));
57 | }
58 |
59 | int getIntProperty(String key, int defaultValue) {
60 | String value = properties.getProperty(key, Integer.toString(defaultValue));
61 | try {
62 | return Integer.parseInt(value);
63 | } catch (NumberFormatException nfe) {
64 | Logger.getLogger(DirectoryChooserProperties.class.getName())
65 | .log(Level.WARNING, "int property not configured properly", nfe);
66 | return 24;
67 | }
68 | }
69 |
70 | void load() {
71 | URL resource = DirectoryChooserProperties.class.getClassLoader().getResource(PROPERTIES_FILE);
72 | if (resource != null) {
73 | try (FileInputStream fis = new FileInputStream(new File(resource.toURI()))) {
74 | properties.load(fis);
75 | } catch (Exception error) {
76 | String message = String.format("Failed to DirectoryChooserProperties from %s (via resource: %s)",
77 | PROPERTIES_FILE, resource);
78 | Logger.getLogger(DirectoryChooserProperties.class.getName())
79 | .log(Level.WARNING, message, error);
80 | }
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/net/raumzeitfalle/fx/dirchooser/DirectoryChooserView.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2021 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.dirchooser;
21 |
22 | import java.io.IOException;
23 | import java.net.URL;
24 | import java.nio.file.Path;
25 |
26 | import javafx.beans.property.ReadOnlyObjectProperty;
27 | import javafx.fxml.FXMLLoader;
28 | import javafx.scene.Parent;
29 | import javafx.scene.layout.AnchorPane;
30 | import net.raumzeitfalle.fx.filechooser.Skin;
31 |
32 | /**
33 | * Creates a Directory Chooser control.
34 | *
35 | * @deprecated As this class is not compatible with JavaFX Scene Builder, this is going to be
36 | * removed in later versions of FXFileChhooser.
37 | */
38 | @Deprecated(since = "0.0.3", forRemoval = true)
39 | public class DirectoryChooserView extends AnchorPane {
40 |
41 | private final DirectoryChooserController controller;
42 |
43 | /**
44 | * Creates a new {@link DirectoryChooserView} with the given {@link Skin}.
45 | *
46 | * @param skin {@link Skin}, controls the appearance of the control
47 | * @throws IOException in case of FXMLLoader failing to read the required FXML file.
48 | */
49 | @Deprecated(since = "0.0.3", forRemoval = true)
50 | public DirectoryChooserView(Skin skin) throws IOException {
51 |
52 | Class> thisClass = getClass();
53 | String fileName = thisClass.getSimpleName() + ".fxml";
54 | URL resource = thisClass.getResource(fileName);
55 | FXMLLoader loader = new FXMLLoader(resource);
56 |
57 | controller = new DirectoryChooserController();
58 | loader.setController(controller);
59 | Parent view = loader.load();
60 | this.getChildren().add(view);
61 |
62 | AnchorPane.setLeftAnchor(view, 0.0);
63 | AnchorPane.setRightAnchor(view, 0.0);
64 | AnchorPane.setTopAnchor(view, 0.0);
65 | AnchorPane.setBottomAnchor(view, 0.0);
66 |
67 | Skin.applyTo(this, skin);
68 |
69 | }
70 |
71 | public ReadOnlyObjectProperty selectedDirectoryProperty() {
72 | return controller.selectedDirectoryProperty();
73 | }
74 |
75 | public void onSelect(Runnable action) {
76 | controller.setOnSelect(action);
77 | }
78 |
79 | public void onCancel(Runnable action) {
80 | controller.setOnCancel(action);
81 | }
82 |
83 | public void shutdown() {
84 | controller.shutdown();
85 | }
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/net/raumzeitfalle/fx/dirchooser/DirectoryIcons.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2019 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.dirchooser;
21 |
22 | import javafx.scene.image.ImageView;
23 | import javafx.scene.layout.StackPane;
24 |
25 | enum DirectoryIcons {
26 |
27 | OPEN("icons/folder-open-32.png"),
28 | CLOSED("icons/folder-closed-32.png"),
29 | OPEN_WITH_FILE("icons/folder-file-open-32.png"),
30 | CLOSED_PLUS("icons/folder-closed-plus-32.png"),
31 | CLOSED_XL("icons/folder-closed-xl-32.png"),
32 | HOST("icons/host-computer-32.png"),
33 | EMPTY("icons/folder-empty-32.png"),
34 | NO_SUBDIRS_XL("icons/folder-closed-unknown-xl-32.png"),
35 | DRIVE("icons/windows-drive-32.png"),
36 | DRIVE_PLUS("icons/windows-drive-plus-32.png"),
37 | DRIVE_XL("icons/windows-drive-xl-32.png"),
38 | DRIVE_EMPTY("icons/windows-drive-empty-32.png");
39 |
40 | private final String iconResource;
41 |
42 | private DirectoryIcons(String iconFileName) {
43 | this.iconResource = DirectoryIcons.class
44 | .getResource(iconFileName)
45 | .toExternalForm();
46 | }
47 |
48 | ImageView create() {
49 | ImageView image = new ImageView(iconResource);
50 | image.preserveRatioProperty().set(true);
51 | image.setFitHeight(DirectoryChooserProperties.getIconSize());
52 | image.getStyleClass().add("directory-icon");
53 | return image;
54 | }
55 |
56 | protected StackPane get() {
57 | StackPane pane = new StackPane();
58 | pane.getChildren().add(create());
59 | pane.setMinWidth(DirectoryChooserProperties.getIconPaneSize());
60 | pane.getStyleClass().add("directory-icon-pane");
61 | return pane;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/net/raumzeitfalle/fx/dirchooser/DirectoryTreeUpdateTask.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2022 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.dirchooser;
21 |
22 | import java.nio.file.Path;
23 | import java.util.List;
24 | import java.util.function.Consumer;
25 | import java.util.logging.Level;
26 | import java.util.logging.Logger;
27 |
28 | import javafx.application.Platform;
29 | import javafx.beans.property.BooleanProperty;
30 | import javafx.beans.property.SimpleBooleanProperty;
31 | import javafx.concurrent.Task;
32 | import javafx.scene.Node;
33 | import javafx.scene.control.TreeItem;
34 |
35 | class DirectoryTreeUpdateTask extends Task {
36 |
37 | private final Path path;
38 | private final DirectoryTreeItem item;
39 | private final BooleanProperty cancelled;
40 | private final Consumer removable;
41 | private final Node itemGraphic;
42 |
43 | DirectoryTreeUpdateTask(Path path, DirectoryTreeItem item, Consumer finalizeAction) {
44 | this.path = path;
45 | this.item = item;
46 | this.cancelled = new SimpleBooleanProperty(false);
47 | this.removable = finalizeAction;
48 | this.itemGraphic = item.getGraphic();
49 | }
50 |
51 | @Override
52 | protected Void call() throws Exception {
53 | DirectoryWalker walker = new DirectoryWalker(path);
54 | List> items = walker.read(cancelled).getChildren();
55 | item.getChildren().clear();
56 | item.getChildren().addAll(items);
57 | return null;
58 | }
59 |
60 | @Override
61 | protected void running() {
62 | super.running();
63 | ProgressIcon progressIcon = new ProgressIcon(32, evt -> cancel(true));
64 | Platform.runLater(() -> item.setGraphic(progressIcon));
65 | }
66 |
67 | @Override
68 | protected void cancelled() {
69 | Logger.getLogger(DirectoryTreeUpdateTask.class.getName()).log(Level.INFO, "contents discovery in {0}", path);
70 | super.cancelled();
71 | cancelled.setValue(true);
72 | removable.accept(path);
73 | Platform.runLater(() -> item.setGraphic(itemGraphic));
74 | }
75 |
76 | @Override
77 | protected void failed() {
78 | super.failed();
79 | removable.accept(path);
80 | Platform.runLater(() -> item.setGraphic(itemGraphic));
81 | }
82 |
83 | @Override
84 | protected void succeeded() {
85 | super.succeeded();
86 | Platform.runLater(() -> {
87 | item.setGraphic(itemGraphic);
88 | if (!item.getChildren().isEmpty() && item.isDirectory()) {
89 | item.setExpanded(true);
90 | item.configureIcon();
91 | }
92 | removable.accept(path);
93 | });
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/net/raumzeitfalle/fx/dirchooser/DirectoryWalker.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2022 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.dirchooser;
21 |
22 | import java.io.File;
23 | import java.io.FileFilter;
24 | import java.nio.file.Path;
25 |
26 | import javafx.beans.property.ReadOnlyBooleanProperty;
27 | import javafx.collections.FXCollections;
28 |
29 | class DirectoryWalker {
30 |
31 | private Path current;
32 |
33 | private int maxDepth;
34 |
35 | private int currentDepth;
36 |
37 | private DirectoryTreeItem rootNode;
38 |
39 | public DirectoryWalker(Path start) {
40 | this(start, 0);
41 | }
42 |
43 | public DirectoryWalker(Path start, int maxDepth) {
44 | this.current = start;
45 | this.maxDepth = maxDepth;
46 | this.currentDepth = 0;
47 | this.rootNode = new DirectoryTreeItem(start);
48 | }
49 |
50 | DirectoryTreeItem read(ReadOnlyBooleanProperty cancelled) {
51 | FileFilter ff = pathname -> {
52 | if (null == pathname) { return false; }
53 | return pathname.isDirectory();
54 | };
55 |
56 | int size = 0;
57 | for (File f : current.toFile().listFiles(ff)) {
58 | addNode(f.toPath(), cancelled);
59 | size += 1;
60 | }
61 | this.rootNode.setSize(size);
62 | return this.rootNode;
63 | }
64 |
65 | private void addNode(Path path, ReadOnlyBooleanProperty cancelled) {
66 | if (currentDepth <= maxDepth) {
67 | if (cancelled.get())
68 | return;
69 | DirectoryTreeItem leaf = new DirectoryTreeItem(path);
70 | rootNode.getChildren().add(leaf);
71 | /*
72 | * TODO: Make the directory tree sortable
73 | * TODO: Make the directory tree filterable
74 | *
75 | */
76 | if (cancelled.get())
77 | return;
78 |
79 | FXCollections.sort(rootNode.getChildren(),
80 | (a, b) -> a.getValue().compareToIgnoreCase(b.getValue()));
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/net/raumzeitfalle/fx/dirchooser/ProgressIcon.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2021 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.dirchooser;
21 |
22 | import javafx.event.ActionEvent;
23 | import javafx.scene.control.ProgressBar;
24 | import javafx.scene.control.Tooltip;
25 | import javafx.scene.layout.AnchorPane;
26 |
27 | class ProgressIcon extends AnchorPane {
28 |
29 | private ProgressBar progressBar;
30 |
31 | /*
32 | * TODO: Decorate the progress counter with an [X] to allow the user to cancel
33 | * an operation.
34 | *
35 | */
36 | public ProgressIcon(double iconSize, javafx.event.EventHandler cancelHandler) {
37 |
38 | progressBar = new ProgressBar();
39 | progressBar.setProgress(-1);
40 | progressBar.setMaxSize(iconSize, iconSize);
41 | progressBar.setPrefSize(iconSize, iconSize);
42 | progressBar.setOnMouseClicked(clickEvent -> {
43 | if (clickEvent.getClickCount() == 2) {
44 | cancelHandler.handle(null);
45 | }
46 | });
47 | getChildren().add(progressBar);
48 |
49 | AnchorPane.setLeftAnchor(progressBar, 0d);
50 | AnchorPane.setRightAnchor(progressBar, 0d);
51 | AnchorPane.setTopAnchor(progressBar, 0d);
52 | AnchorPane.setBottomAnchor(progressBar, 0d);
53 |
54 | setMinWidth(iconSize * 1.5);
55 |
56 | progressBar.getStyleClass().add("directory-progress-icon");
57 | getStyleClass().add("directory-icon-pane");
58 |
59 | Tooltip tooltip = new Tooltip("Double click to abort directory search!");
60 | Tooltip.install(progressBar, tooltip);
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/net/raumzeitfalle/fx/filechooser/DirectoryChooserOption.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2022 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import java.util.function.Function;
23 |
24 | import net.raumzeitfalle.fx.dirchooser.DirectoryChooser;
25 |
26 | public enum DirectoryChooserOption implements Function {
27 | JAVAFX_PLATFORM {
28 | @Override
29 | public PathUpdateHandler apply(FileChooser fileChooser) {
30 | return FXDirectoryChooser.createIn(fileChooser.currentSearchPath(),
31 | () -> fileChooser.getWindow());
32 | }
33 | },
34 | CUSTOM {
35 | @Override
36 | public PathUpdateHandler apply(FileChooser fileChooser) {
37 | return new DirectoryChooser.DirChooserPathUpdateHandler(fileChooser);
38 | }
39 | };
40 | }
41 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/net/raumzeitfalle/fx/filechooser/FXDirectoryChooser.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2019 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import java.io.File;
23 | import java.nio.file.Path;
24 | import java.nio.file.Paths;
25 | import java.util.Objects;
26 | import java.util.Optional;
27 | import java.util.function.Consumer;
28 | import java.util.function.Supplier;
29 |
30 | import javafx.application.Platform;
31 | import javafx.beans.property.ObjectProperty;
32 | import javafx.stage.DirectoryChooser;
33 | import javafx.stage.Window;
34 |
35 | /*
36 | * TODO: Functionality will become internal-API.
37 | * TODO: Remove the old style FX Directory Chooser.
38 | */
39 | public class FXDirectoryChooser implements PathUpdateHandler {
40 |
41 | public static FXDirectoryChooser createIn(ObjectProperty startLocation, Supplier ownerProvider) {
42 | Objects.requireNonNull(startLocation, "startLocation must not be null");
43 | Path location = startLocation.get();
44 | if (null == location) {
45 | location = Paths.get("./");
46 | }
47 | return new FXDirectoryChooser(location, ownerProvider);
48 | }
49 |
50 | public static FXDirectoryChooser createIn(Path startLocation, Supplier ownerProvider) {
51 | Objects.requireNonNull(ownerProvider, "ownerProvider must not be null");
52 | Objects.requireNonNull(startLocation, "startLocation for file search must not be null.");
53 | Path location = startLocation;
54 | if (String.valueOf(startLocation).equals("")) {
55 | location = Paths.get("./");
56 | }
57 | return new FXDirectoryChooser(location, ownerProvider);
58 | }
59 |
60 | private final DirectoryChooser dc;
61 |
62 | private final Supplier ownerProvider;
63 |
64 | private FXDirectoryChooser(Path startLocation, Supplier ownerProvider) {
65 | this.dc = new DirectoryChooser();
66 | this.dc.setInitialDirectory(startLocation.toFile());
67 | this.ownerProvider = Objects.requireNonNull(ownerProvider, "ownerProvider must not be null");
68 | }
69 |
70 | public void getUpdate(Consumer update) {
71 | Platform.runLater(() -> Optional.ofNullable(dc.showDialog(ownerProvider.get()))
72 | .map(File::toPath)
73 | .ifPresent(update.andThen(this::changeDir)));
74 | }
75 |
76 | private void changeDir(Path newLocation) {
77 | this.dc.setInitialDirectory(newLocation.toFile());
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/net/raumzeitfalle/fx/filechooser/FileChooserProperties.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2022 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import java.io.File;
23 | import java.io.FileInputStream;
24 | import java.net.URL;
25 | import java.util.Properties;
26 | import java.util.logging.Level;
27 | import java.util.logging.Logger;
28 |
29 | public enum FileChooserProperties {
30 | INSTANCE;
31 |
32 | static {
33 | INSTANCE.load();
34 | }
35 |
36 | static final String PROPERTIES_FILE = "filechooser.properties";
37 | static final String PROPERTY_ICON_SIZE = "file.chooser.icon.size";
38 |
39 | private final Properties properties;
40 |
41 |
42 | private FileChooserProperties() {
43 | this.properties = new Properties();
44 | }
45 |
46 | public static int getIconSize() {
47 | return INSTANCE.getIntProperty(PROPERTY_ICON_SIZE, 32);
48 | }
49 |
50 | public static void setIconSize(int newIconSize) {
51 | INSTANCE.properties
52 | .setProperty(PROPERTY_ICON_SIZE,
53 | Integer.toString(newIconSize));
54 | }
55 |
56 | int getIntProperty(String key, int defaultValue) {
57 | String value = properties.getProperty(key, Integer.toString(defaultValue));
58 | try {
59 | return Integer.parseInt(value);
60 | } catch (NumberFormatException nfe) {
61 | Logger.getLogger(FileChooserProperties.class.getName())
62 | .log(Level.WARNING, "int property not configured properly", nfe);
63 | return 24;
64 | }
65 | }
66 |
67 | void load() {
68 | URL resource = FileChooserProperties.class.getClassLoader().getResource(PROPERTIES_FILE);
69 | if (resource != null) {
70 | try (FileInputStream fis = new FileInputStream(new File(resource.toURI()))) {
71 | properties.load(fis);
72 | } catch (Exception error) {
73 | String message = String.format("Failed to FileChooserProperties from %s (via resource: %s)",
74 | PROPERTIES_FILE, resource);
75 | Logger.getLogger(FileChooserProperties.class.getName())
76 | .log(Level.WARNING, message, error);
77 | }
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/net/raumzeitfalle/fx/filechooser/FileChooserViewOption.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2020 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | enum FileChooserViewOption {
23 |
24 | /**
25 | * Configures the FileChooserView and Model so, that it will work in an independent JavaFX stage or inside a JFXPanel.
26 | * The view will provide its own OKAY and CANCEL buttons.
27 | */
28 | STAGE,
29 |
30 | /**
31 | * Configures the FileChooserView and Model so, that it will work inside a JavaFX Dialog.
32 | * E.g. JavaFX dialogs already provide OKAY and CANCEL buttons. In this case, the buttons provided by the view will be hidden.
33 | */
34 | DIALOG;
35 | }
36 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/net/raumzeitfalle/fx/filechooser/FileIcons.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2022 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import javafx.scene.image.ImageView;
23 | import javafx.scene.layout.StackPane;
24 |
25 | enum FileIcons {
26 |
27 | CSV(".csv", "icons/file-csv.png"),
28 | DOC(".doc", "icons/file-doc.png"),
29 | DOCX(".docx", "icons/file-docx4.png"),
30 | UNKNOWN(null, "icons/file-unknown.png"),
31 | XLS(".xls", "icons/file-xls.png"),
32 | XLSX(".xlsx", "icons/file-xlsx4.png"),
33 | TXT(".txt", "icons/file-txt.png"),
34 | XML(".xml", "icons/file-xml.png");
35 |
36 | private final String suffix;
37 | private final String iconResource;
38 |
39 | private FileIcons(String suffix, String iconFileName) {
40 | this.suffix = suffix;
41 | this.iconResource = FileIcons.class
42 | .getResource(iconFileName)
43 | .toExternalForm();
44 | }
45 |
46 | ImageView create() {
47 | ImageView image = new ImageView(iconResource);
48 | image.preserveRatioProperty().set(true);
49 | image.setFitHeight(FileChooserProperties.getIconSize());
50 | image.getStyleClass().add("file-icon");
51 | return image;
52 | }
53 |
54 | private static ImageView create(String file) {
55 | if (null == file) {
56 | return FileIcons.UNKNOWN.create();
57 | }
58 | String fileName = file.toLowerCase();
59 | for (FileIcons icon : FileIcons.values()) {
60 | String suffix = icon.suffix;
61 | if (null != icon.suffix && fileName.endsWith(suffix)) {
62 | return icon.create();
63 | }
64 | }
65 | return FileIcons.UNKNOWN.create();
66 | }
67 |
68 | static StackPane fromFile(IndexedPath path) {
69 | return fromFile(path.toString());
70 | }
71 |
72 | static StackPane fromFile(String file) {
73 | StackPane pane = new StackPane();
74 | ImageView image = create(file);
75 | pane.getChildren().add(image);
76 | pane.setMinWidth(FileChooserProperties.getIconSize() * 1.5);
77 | pane.getStyleClass().add("file-icon-pane");
78 | return pane;
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/net/raumzeitfalle/fx/filechooser/FilesListCell.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2022 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import java.nio.file.attribute.FileTime;
23 | import java.time.LocalDateTime;
24 | import java.time.ZoneId;
25 | import java.time.format.DateTimeFormatter;
26 |
27 | import javafx.scene.control.Label;
28 | import javafx.scene.control.ListCell;
29 | import javafx.scene.layout.GridPane;
30 | import javafx.scene.layout.Pane;
31 | import javafx.scene.layout.Priority;
32 |
33 | class FilesListCell extends ListCell {
34 |
35 | private static final String DATE_TIME_FORMAT_PATTERN = "yyyy-MM-dd - HH:mm:ss";
36 |
37 | private static final String FILE_ICON_LABEL = "file-icon-label";
38 |
39 | @Override
40 | protected void updateItem(IndexedPath item, boolean empty) {
41 | super.updateItem(item, empty);
42 | updateView();
43 | }
44 |
45 | private void updateView() {
46 | if (getItem() != null) {
47 | GridPane gridPane = new GridPane();
48 | gridPane.getStyleClass().add(FILE_ICON_LABEL);
49 |
50 | Pane icon = FileIcons.fromFile(getItem());
51 | icon.setId("fileListCell-fileTypeIcon");
52 |
53 | gridPane.addColumn(0, icon);
54 | GridPane.setHgrow(icon, Priority.SOMETIMES);
55 |
56 | Label fileName = new Label(String.valueOf(getItem()));
57 | fileName.getStyleClass().add(FILE_ICON_LABEL);
58 | fileName.setId("fileListCell-fileName");
59 |
60 | gridPane.addColumn(1, fileName);
61 | GridPane.setHgrow(fileName, Priority.ALWAYS);
62 |
63 | Label date = new Label("");
64 | FileTime time = getItem().getTimestamp();
65 | LocalDateTime timestamp = LocalDateTime.from(time.toInstant().atZone(ZoneId.systemDefault()));
66 | date.setText(DateTimeFormatter.ofPattern(DATE_TIME_FORMAT_PATTERN).format(timestamp));
67 | date.setId("fileListCell-fileDate");
68 |
69 | date.getStyleClass().add(FILE_ICON_LABEL);
70 | gridPane.addColumn(2, date);
71 | GridPane.setHgrow(date, Priority.NEVER);
72 |
73 | setGraphic(gridPane);
74 | } else {
75 | setText(null);
76 | setGraphic(null);
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/net/raumzeitfalle/fx/filechooser/HideableView.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2019 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | /**
23 | * Any container (e.g. Stage, Dialog, JFXPanel) which can be hidden, shall implement this interface.
24 | * In some cases, it is not possible to directly close the window which contains the file chooser.
25 | * Therefore either the type which represents the window should implement this interface or a
26 | * Lambda can be created which ensures, that if requested, the window is closed properly.
27 | */
28 | @FunctionalInterface
29 | interface HideableView {
30 | void closeView();
31 | }
32 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/net/raumzeitfalle/fx/filechooser/IndexedPath.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2022 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import java.io.IOException;
23 | import java.nio.file.Files;
24 | import java.nio.file.Path;
25 | import java.nio.file.attribute.BasicFileAttributes;
26 | import java.nio.file.attribute.FileTime;
27 | import java.util.concurrent.TimeUnit;
28 | import java.util.logging.Level;
29 | import java.util.logging.Logger;
30 |
31 | final class IndexedPath {
32 |
33 | private static final Logger LOGGER = Logger.getLogger(IndexedPath.class.getName());
34 |
35 | public static IndexedPath valueOf(Path path) {
36 | FileTime timestamp;
37 | try {
38 | timestamp = getTimestamp(path);
39 | } catch (IOException e) {
40 | timestamp = FileTime.from(0, TimeUnit.MICROSECONDS);
41 | String message = String.format("Could not determine lastModified timestamp for %s, returning %s instead.",
42 | path, timestamp);
43 | LOGGER.log(Level.SEVERE, message, e);
44 | }
45 | return new IndexedPath(path, timestamp);
46 | }
47 |
48 | private static FileTime getTimestamp(Path path) throws IOException {
49 | BasicFileAttributes attributes = Files.readAttributes(path, BasicFileAttributes.class);
50 | FileTime lastModified = attributes.lastModifiedTime();
51 | FileTime created = attributes.creationTime();
52 | if (lastModified.compareTo(created) > 0) {
53 | return lastModified;
54 | } else {
55 | return created;
56 | }
57 | }
58 |
59 | private final byte[] fileName;
60 | private final long timestamp;
61 |
62 | IndexedPath(Path path, FileTime timestamp) {
63 | this.fileName = path.getFileName().toString().getBytes();
64 | this.timestamp = timestamp.to(TimeUnit.MILLISECONDS);
65 | }
66 |
67 | public final FileTime getTimestamp() {
68 | return FileTime.from(timestamp, TimeUnit.MILLISECONDS);
69 | }
70 |
71 | public final Path asPath(Path location) {
72 | return location.resolve(toString());
73 | }
74 |
75 | @Override
76 | public final String toString() {
77 | return new String(fileName);
78 | }
79 |
80 | int compareByName(IndexedPath other) {
81 | return toString().compareTo(other.toString());
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/net/raumzeitfalle/fx/filechooser/Invoke.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2019 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import java.time.Duration;
23 | import java.util.concurrent.ExecutionException;
24 | import java.util.concurrent.FutureTask;
25 | import java.util.concurrent.TimeUnit;
26 | import java.util.concurrent.TimeoutException;
27 | import java.util.function.Consumer;
28 | import java.util.function.Supplier;
29 | import java.util.logging.Level;
30 | import java.util.logging.Logger;
31 |
32 | import javafx.application.Platform;
33 |
34 | class Invoke {
35 |
36 | private Invoke() {
37 |
38 | }
39 |
40 | static void later(Supplier action) {
41 | Platform.runLater(action::get);
42 | }
43 |
44 | static void later(T value, Consumer consumingAction) {
45 | Platform.runLater(() -> consumingAction.accept(value));
46 | }
47 |
48 | static void laterWithDelay(Duration duration, Runnable r) {
49 | Platform.runLater(() -> {
50 | try {
51 | Thread.sleep(duration.toMillis());
52 | } catch (InterruptedException e) {
53 | Thread.currentThread().interrupt();
54 | }
55 | r.run();
56 | });
57 | }
58 |
59 | static void andWaitWithoutException(Runnable r) {
60 | try {
61 | andWait(r);
62 | } catch (InterruptedException | ExecutionException e) {
63 | Thread.currentThread().interrupt();
64 | }
65 | }
66 |
67 | static void andWaitWithoutException(Runnable r, long millis) {
68 | try {
69 | andWait(r, millis);
70 | } catch (InterruptedException | ExecutionException e) {
71 | Thread.currentThread().interrupt();
72 | } catch (TimeoutException t) {
73 | Logger.getLogger(Invoke.class.getName())
74 | .log(Level.SEVERE, "Timeout!", t);
75 | }
76 | }
77 |
78 | static void andWait(Runnable r) throws InterruptedException, ExecutionException {
79 | FutureTask> task = new FutureTask<>(r, null);
80 | Platform.runLater(task);
81 | task.get();
82 | }
83 |
84 | static void andWait(Runnable r, long timeout) throws InterruptedException, ExecutionException, TimeoutException {
85 | FutureTask> task = new FutureTask<>(r, null);
86 | Platform.runLater(task);
87 | task.get(timeout, TimeUnit.MILLISECONDS);
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/net/raumzeitfalle/fx/filechooser/LocationMenuItemFactory.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2020 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import java.util.Objects;
23 | import java.util.function.Consumer;
24 | import java.util.function.Function;
25 |
26 | import javafx.scene.control.MenuItem;
27 | import net.raumzeitfalle.fx.filechooser.locations.Location;
28 |
29 | class LocationMenuItemFactory implements Function {
30 |
31 | private final Consumer pathConsumer;
32 |
33 | LocationMenuItemFactory(Consumer pathConsumer) {
34 | this.pathConsumer = Objects.requireNonNull(pathConsumer, "pathConsumer must not be null.");
35 | }
36 |
37 | @Override
38 | public LocationMenuItem apply(Location location) {
39 | LocationMenuItem item = new LocationMenuItem(location);
40 | item.setOnAction(e -> Invoke.later(location, pathConsumer));
41 | return item;
42 | }
43 | }
44 |
45 | class LocationMenuItem extends MenuItem {
46 |
47 | private final Location location;
48 |
49 | LocationMenuItem(Location location) {
50 | this.location = Objects.requireNonNull(location, "Given location instance must never be null.");
51 | setText(location.getName());
52 | setDisable(!location.exists());
53 | }
54 |
55 | public boolean matchesLocation(Location otherLocation) {
56 | return this.location.equals(otherLocation);
57 | }
58 |
59 | @Override
60 | public boolean equals(Object o) {
61 | if (this == o) return true;
62 | if (!(o instanceof LocationMenuItem)) return false;
63 | LocationMenuItem that = (LocationMenuItem) o;
64 | return location.equals(that.location);
65 | }
66 |
67 | @Override
68 | public int hashCode() {
69 | return location.hashCode() + 13;
70 | }
71 | }
72 |
73 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/net/raumzeitfalle/fx/filechooser/PathComparator.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2022 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import java.nio.file.Path;
23 | import java.util.Comparator;
24 |
25 | /**
26 | * Provides various {@link Comparator} variants to compare {@link Path} objects.
27 | */
28 | class PathComparator {
29 |
30 | static Comparator byName() {
31 | return (IndexedPath a, IndexedPath b) -> a.compareByName(b);
32 | }
33 |
34 | static Comparator byTimestamp() {
35 | return (IndexedPath a, IndexedPath b) -> a.getTimestamp().compareTo(b.getTimestamp());
36 | }
37 |
38 | private PathComparator() {
39 | // provides short cuts for commonly used comparators
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/net/raumzeitfalle/fx/filechooser/PathUpdateHandler.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2019 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import java.nio.file.Path;
23 | import java.util.function.Consumer;
24 |
25 | @FunctionalInterface
26 | public interface PathUpdateHandler {
27 | void getUpdate(Consumer update);
28 | }
29 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/net/raumzeitfalle/fx/filechooser/RefreshBuffer.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2019 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import java.nio.file.Path;
23 | import java.util.ArrayList;
24 | import java.util.List;
25 | import java.util.concurrent.atomic.AtomicReference;
26 | import java.util.concurrent.locks.ReentrantLock;
27 |
28 | import javafx.application.Platform;
29 | import javafx.collections.ObservableList;
30 |
31 | final class RefreshBuffer {
32 |
33 | static RefreshBuffer get(FindFilesTask task, int expectedNumberOfElements, ObservableList target) {
34 | int bufferSize = determineBufferSize(expectedNumberOfElements);
35 | return new RefreshBuffer(task, bufferSize, target);
36 | }
37 |
38 | private final List cache;
39 |
40 | private final AtomicReference> atomicCache;
41 |
42 | private final ReentrantLock lock = new ReentrantLock();
43 |
44 | private final ObservableList target;
45 |
46 | private final int desiredCacheSize;
47 |
48 | private final FindFilesTask task;
49 |
50 | private RefreshBuffer(FindFilesTask task, int bufferSize, ObservableList target) {
51 | this.cache = new ArrayList<>(2 * bufferSize);
52 | this.target = target;
53 | this.desiredCacheSize = bufferSize;
54 | this.atomicCache = new AtomicReference<>(cache);
55 | this.task = task;
56 | }
57 |
58 | void update(Path file) {
59 | cache.add(IndexedPath.valueOf(file));
60 | if (!task.isCancelled() && currentCacheSize() > desiredCacheSize) {
61 | flush();
62 | }
63 | }
64 |
65 | private int currentCacheSize() {
66 | return cache.size();
67 | }
68 |
69 | void flush() {
70 | this.lock.lock();
71 | try {
72 | IndexedPath[] update = this.atomicCache.get().toArray(new IndexedPath[0]);
73 | Platform.runLater(() -> target.addAll(update));
74 | this.atomicCache.get().clear();
75 | } finally {
76 | this.lock.unlock();
77 | }
78 | }
79 |
80 | static int determineBufferSize(int items) {
81 | if (items > 500_000)
82 | return 1000;
83 |
84 | if (items > 100_000)
85 | return 500;
86 |
87 | if (items > 50_000)
88 | return 200;
89 |
90 | if (items > 15_000)
91 | return 100;
92 |
93 | if (items > 5_000)
94 | return 50;
95 |
96 | if (items > 1_000)
97 | return 20;
98 |
99 | return 10;
100 | }
101 |
102 | }
103 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/net/raumzeitfalle/fx/filechooser/Skin.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2021 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import java.net.URL;
23 |
24 | import javafx.scene.Parent;
25 | import javafx.scene.control.Dialog;
26 |
27 | public enum Skin {
28 |
29 | NONE,
30 | MODENA,
31 | DARK;
32 |
33 | public static void applyTo(T parent, Skin skin) {
34 | if (NONE.equals(skin)) {
35 | return;
36 | }
37 |
38 | String css = skin.getCssLocation(parent);
39 | if (null != css) {
40 | parent.getStylesheets().add(css);
41 | parent.applyCss();
42 | }
43 | }
44 |
45 | public static void removeFrom(T parent, Skin skin) {
46 | if (NONE.equals(skin)) {
47 | return;
48 | }
49 |
50 | String css = skin.getCssLocation(parent);
51 | if (null != css) {
52 | parent.getStylesheets().remove(css);
53 | parent.applyCss();
54 | }
55 | }
56 |
57 | public static > void applyToDialog(T dialog, Skin skin) {
58 | String css = skin.getCssLocation(dialog);
59 | if (null != css) {
60 | dialog.getDialogPane().getStylesheets().add(css);
61 | }
62 | }
63 |
64 | private String getStyleName() {
65 | String cssName = name().substring(1).toLowerCase();
66 | String first = new String(new char[] {name().charAt(0)});
67 | return first + cssName;
68 | }
69 |
70 | private static String getClassName(Object parent) {
71 | return parent.getClass().getSimpleName();
72 | }
73 |
74 | private String getCssLocation(Object parent) {
75 |
76 | String className = getClassName(parent);
77 | String styleName = getStyleName();
78 | String styleSheetName = className + styleName + ".css";
79 |
80 | URL url = parent.getClass().getResource(styleSheetName);
81 |
82 | if (url == null) {
83 | return null;
84 | }
85 | return url.toExternalForm();
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/net/raumzeitfalle/fx/filechooser/SwingDialogReturnValues.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2019 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import javax.swing.JFileChooser;
23 |
24 | public enum SwingDialogReturnValues {
25 |
26 | /**
27 | * Return value if cancel is chosen.
28 | */
29 | CANCEL_OPTION(JFileChooser.CANCEL_OPTION),
30 |
31 | /**
32 | * Return value if approve (yes, ok) is chosen.
33 | */
34 | APPROVE_OPTION(JFileChooser.APPROVE_OPTION),
35 |
36 | /**
37 | * Return value if an error occurred.
38 | */
39 | ERROR_OPTION(JFileChooser.ERROR_OPTION);
40 |
41 | private final int returnValue;
42 |
43 | private SwingDialogReturnValues(int returnValue) {
44 | this.returnValue = returnValue;
45 | }
46 |
47 | public int getValue() {
48 | return this.returnValue;
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/net/raumzeitfalle/fx/filechooser/SwingFileChooserProperties.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2022 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import java.io.File;
23 | import java.io.FileInputStream;
24 | import java.net.URL;
25 | import java.util.Properties;
26 | import java.util.logging.Level;
27 | import java.util.logging.Logger;
28 |
29 | enum SwingFileChooserProperties {
30 | INSTANCE;
31 |
32 | static {
33 | INSTANCE.load();
34 | }
35 |
36 | static final String PROPERTIES_FILE = "swingfilechooser.properties";
37 | static final String PROPERTY_USE_JAVAFX_DIRCHOOSER = "use.javafx.platform.directory.chooser";
38 |
39 | private final Properties properties;
40 |
41 | private SwingFileChooserProperties() {
42 | this.properties = new Properties();
43 | }
44 |
45 | public static boolean usesJavaFXDirectoryChooser() {
46 | return INSTANCE.getBooleanProperty(PROPERTY_USE_JAVAFX_DIRCHOOSER, false);
47 | }
48 |
49 | public static void setUseJavaFXDirectoryChooser(boolean toggle) {
50 | INSTANCE.properties
51 | .setProperty(PROPERTY_USE_JAVAFX_DIRCHOOSER, Boolean.toString(toggle));
52 | }
53 |
54 |
55 | boolean getBooleanProperty(String key, boolean defaultValue) {
56 | return Boolean.parseBoolean(properties.getProperty(key, String.valueOf(defaultValue)));
57 | }
58 |
59 | void load() {
60 | URL resource = SwingFileChooserProperties.class.getClassLoader().getResource(PROPERTIES_FILE);
61 | if (resource != null) {
62 | try (FileInputStream fis = new FileInputStream(new File(resource.toURI()))) {
63 | properties.load(fis);
64 | } catch (Exception error) {
65 | String message = String.format("Failed to read SwingFileChooserProperties size from %s (via resource: %s)",
66 | PROPERTIES_FILE, resource);
67 | Logger.getLogger(SwingFileChooserProperties.class.getName())
68 | .log(Level.WARNING, message, error);
69 | }
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/net/raumzeitfalle/fx/filechooser/UpdateService.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2019 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import java.nio.file.Path;
23 | import java.util.logging.Level;
24 | import java.util.logging.Logger;
25 |
26 | import javafx.beans.property.ObjectProperty;
27 | import javafx.beans.property.ReadOnlyBooleanProperty;
28 | import javafx.beans.property.ReadOnlyDoubleProperty;
29 |
30 | interface UpdateService {
31 | void restartIn(Path location);
32 | ObjectProperty searchPathProperty();
33 | void refresh();
34 | void startUpdate();
35 | void cancelUpdate();
36 | ReadOnlyBooleanProperty runningProperty();
37 | ReadOnlyDoubleProperty progressProperty();
38 |
39 | /**
40 | * Waits by default 1000ms.
41 | * Only to be used for testing or debugging.
42 | */
43 | default void waitUntilFinished() {
44 | waitUntilFinished(1000);
45 | }
46 |
47 | private void waitUntilFinished(long millis) {
48 | if (this instanceof FileUpdateService service) {
49 | service.waitUntilFinished();
50 | } else {
51 | try {
52 | Thread.sleep(millis);
53 | } catch (InterruptedException e) {
54 | Thread.currentThread().interrupt();
55 | Logger.getLogger(UpdateService.class.getName())
56 | .log(Level.WARNING, "Unexpected interruption during wait...", e);
57 | }
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/net/raumzeitfalle/fx/filechooser/locations/Location.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2019 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser.locations;
21 |
22 | import java.nio.file.Path;
23 | import java.util.Objects;
24 |
25 | public abstract class Location implements Comparable {
26 |
27 | public abstract String getName();
28 |
29 | public abstract boolean exists();
30 |
31 | public abstract Path getPath();
32 |
33 | @Override
34 | public int compareTo(Location o) {
35 | return this.getName().compareToIgnoreCase(o.getName());
36 | }
37 |
38 | @Override
39 | public int hashCode() {
40 | return Objects.hash(getPath(), getName());
41 | }
42 |
43 | @Override
44 | public boolean equals(Object obj) {
45 |
46 | if (null == obj)
47 | return false;
48 |
49 | if (this == obj)
50 | return true;
51 |
52 | if (!(obj instanceof Location))
53 | return false;
54 |
55 | Location other = (Location) obj;
56 |
57 | return Objects.equals(getPath(), other.getPath()) && Objects.equals(getName(), other.getName());
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/net/raumzeitfalle/fx/filechooser/locations/Locations.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2019 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser.locations;
21 |
22 | import java.io.File;
23 | import java.nio.file.Path;
24 | import java.util.Objects;
25 |
26 | public class Locations {
27 |
28 | public static Location at(Path path) {
29 | File file = Objects.requireNonNull(path, "path must not be null").toFile();
30 | if (null != path.getParent() && file.isFile()) {
31 | Path parent = path.getParent();
32 | return new NamedLocation(parent);
33 | }
34 | return withName(path.toString(), path);
35 | }
36 |
37 | public static Location withName(String name, Path path) {
38 | return new NamedLocation(name, path);
39 | }
40 |
41 | private Locations() {
42 | /*
43 | * Collection of static factory methods, not intended for instantiation.
44 | *
45 | */
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/filechooser/src/main/java/net/raumzeitfalle/fx/filechooser/locations/NamedLocation.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2019 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser.locations;
21 |
22 | import java.nio.file.Path;
23 | import java.util.Objects;
24 |
25 | class NamedLocation extends Location {
26 |
27 | private final String name;
28 |
29 | private final Path directory;
30 |
31 | protected NamedLocation(Path parent) {
32 | this(createName(parent), parent);
33 | }
34 |
35 | private static String createName(Path location) {
36 | Objects.requireNonNull(location, "location must not be null");
37 | return location.toString();
38 | }
39 |
40 | protected NamedLocation(String name, Path path) {
41 | this.name = Objects.requireNonNull(name, "name must not be null");
42 | this.directory = Objects.requireNonNull(path, "path must not be null");
43 | }
44 |
45 | @Override
46 | public String getName() {
47 | return this.name;
48 | }
49 |
50 | @Override
51 | public boolean exists() {
52 | return directory.toFile().exists();
53 | }
54 |
55 | @Override
56 | public Path getPath() {
57 | return this.directory;
58 | }
59 |
60 | @Override
61 | public boolean equals(Object other) {
62 | return super.equals(other);
63 | }
64 |
65 | @Override
66 | public int hashCode() {
67 | return super.hashCode();
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/filechooser/src/main/resources/directorychooser.properties:
--------------------------------------------------------------------------------
1 | directory.chooser.icon.size=24
--------------------------------------------------------------------------------
/filechooser/src/main/resources/filechooser.properties:
--------------------------------------------------------------------------------
1 | file.chooser.icon.size=24
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/DirectoryChooser.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/DirectoryChooserDark.css:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2022 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 |
21 | .button {
22 | -fx-font-size: 13px;
23 | -fx-font-weight: bold;
24 | }
25 |
26 | .progress-indicator {
27 | -fx-text-fill: white;
28 | }
29 |
30 | .progress-bar .track{
31 | -fx-accent: #ffa700;
32 | -fx-background-color: black;
33 | -fx-background-insets: 1;
34 | -fx-background-radius: 0, 0, 0, 0;
35 | }
36 |
37 | .progress-bar .bar {
38 | -fx-accent: #ffa700;
39 | -fx-background-color: #ffa700;
40 | -fx-background-insets: 1, 0, 1, 0;
41 | -fx-background-radius: 0, 0, 0, 0;
42 | }
43 |
44 | .menu-button {
45 | -fx-font-size: 13px;
46 | -fx-font-weight: bold;
47 | }
48 |
49 | .tree-view .tree-view {
50 | -fx-blend-mode: screen;
51 | -fx-focus-color: transparent;
52 | -fx-faint-focus-color:transparent;
53 | }
54 |
55 | .tree-cell:filled:selected:focused, .tree-cell:filled:selected {
56 | -fx-background-color: #ffa700;
57 | -fx-text-fill: black;
58 | }
59 |
60 | .tree-cell:filled:hover {
61 | -fx-background-color: #212121;
62 | -fx-text-fill: white;
63 | }
64 |
65 | .text-field {
66 | -fx-blend-mode: screen;
67 | -fx-font-size: 13px;
68 | -fx-font-weight: bold;
69 | -fx-prompt-text-fill: black;
70 |
71 | -fx-focus-color : transparent;
72 | -fx-faint-focus-color : transparent;
73 | -fx-highlight-fill: #ffa700;
74 | -fx-highlight-text-fill: black;
75 | }
76 |
77 | .counter-label {
78 | -fx-font-size: 13px;
79 | -fx-font-weight: bold;
80 | -fx-text-fill: black;
81 | }
82 |
83 | .split-menu-button {
84 | -fx-font-size: 13px;
85 | -fx-font-weight: bold;
86 | }
87 |
88 | .filter-icon {
89 | -fx-fill: rgba(255,167,0,0.53);
90 | -fx-stroke-width: 1px;
91 | -fx-stroke: black;
92 | }
93 |
94 | .root {
95 | -fx-base: rgb(50, 50, 50);
96 | -fx-background: rgb(50, 50, 50);
97 | -fx-control-inner-background: rgb(50, 50, 50);
98 |
99 | -fx-accent: transparent;
100 | /* -fx-focus-color: #ffa700;
101 | -fx-faint-focus-color: #ffa70066; */
102 |
103 | -fx-focus-color: transparent;
104 | -fx-faint-focus-color:transparent;
105 | }
106 |
107 | .tool-bar-icon {
108 | -fx-fill: #ffa700;
109 | -fx-highlight-text-fill: #000000;
110 | }
111 |
112 | .menu-item {
113 | /* -fx-accent: #ffa700; */
114 | -fx-accent: rgba(255,167,0,0.8);
115 | -fx-fill: #ffa700;
116 | }
117 |
118 | .menu-item-icon {
119 | -fx-fill: #ffa700;
120 | }
121 |
122 | .scroll-bar .thumb {
123 | -fx-background-insets: 2, 0, 0;
124 | -fx-background-color:derive(black, 5%);
125 | }
126 |
127 | .scroll-bar .thumb:hover {
128 | -fx-background-color:derive(black, 10%);
129 | }
130 |
131 | .scroll-bar .increment-button,.scroll-bar .decrement-button {
132 | -fx-background-color:derive(black, 5%);
133 | -fx-padding: 5;
134 | }
135 |
136 | .scroll-bar .increment-button:hover,.scroll-bar .decrement-button:hover {
137 | -fx-background-color:derive(black, 10%);
138 | -fx-padding: 5;
139 | }
140 |
141 | .scroll-bar .corner {
142 | -fx-background-color:transparent;
143 | }
144 |
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/DirectoryChooserViewDark.css:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2019 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 |
21 | .button {
22 | -fx-font-size: 13px;
23 | -fx-font-weight: bold;
24 | }
25 |
26 | .progress-indicator {
27 | -fx-text-fill: white;
28 | }
29 |
30 | .progress-bar .track{
31 | -fx-accent: #ffa700;
32 | -fx-background-color: black;
33 | -fx-background-insets: 1;
34 | -fx-background-radius: 0, 0, 0, 0;
35 | }
36 |
37 | .progress-bar .bar {
38 | -fx-accent: #ffa700;
39 | -fx-background-color: #ffa700;
40 | -fx-background-insets: 1, 0, 1, 0;
41 | -fx-background-radius: 0, 0, 0, 0;
42 | }
43 |
44 | .menu-button {
45 | -fx-font-size: 13px;
46 | -fx-font-weight: bold;
47 | }
48 |
49 | .tree-view .tree-view {
50 | -fx-blend-mode: screen;
51 | -fx-focus-color: transparent;
52 | -fx-faint-focus-color:transparent;
53 | }
54 |
55 | .tree-cell:filled:selected:focused, .tree-cell:filled:selected {
56 | -fx-background-color: #ffa700;
57 | -fx-text-fill: black;
58 | }
59 |
60 | .tree-cell:filled:hover {
61 | -fx-background-color: #212121;
62 | -fx-text-fill: white;
63 | }
64 |
65 | .text-field {
66 | -fx-blend-mode: screen;
67 | -fx-font-size: 13px;
68 | -fx-font-weight: bold;
69 | -fx-prompt-text-fill: black;
70 |
71 | -fx-focus-color : transparent;
72 | -fx-faint-focus-color : transparent;
73 | -fx-highlight-fill: #ffa700;
74 | -fx-highlight-text-fill: black;
75 | }
76 |
77 | .counter-label {
78 | -fx-font-size: 13px;
79 | -fx-font-weight: bold;
80 | -fx-text-fill: black;
81 | }
82 |
83 | .split-menu-button {
84 | -fx-font-size: 13px;
85 | -fx-font-weight: bold;
86 | }
87 |
88 | .filter-icon {
89 | -fx-fill: rgba(255,167,0,0.53);
90 | -fx-stroke-width: 1px;
91 | -fx-stroke: black;
92 | }
93 |
94 | .root {
95 | -fx-base: rgb(50, 50, 50);
96 | -fx-background: rgb(50, 50, 50);
97 | -fx-control-inner-background: rgb(50, 50, 50);
98 |
99 | -fx-accent: transparent;
100 | /* -fx-focus-color: #ffa700;
101 | -fx-faint-focus-color: #ffa70066; */
102 |
103 | -fx-focus-color: transparent;
104 | -fx-faint-focus-color:transparent;
105 | }
106 |
107 | .tool-bar-icon {
108 | -fx-fill: #ffa700;
109 | -fx-highlight-text-fill: #000000;
110 | }
111 |
112 | .menu-item {
113 | /* -fx-accent: #ffa700; */
114 | -fx-accent: rgba(255,167,0,0.8);
115 | -fx-fill: #ffa700;
116 | }
117 |
118 | .menu-item-icon {
119 | -fx-fill: #ffa700;
120 | }
121 |
122 | .scroll-bar .thumb {
123 | -fx-background-insets: 2, 0, 0;
124 | -fx-background-color:derive(black, 5%);
125 | }
126 |
127 | .scroll-bar .thumb:hover {
128 | -fx-background-color:derive(black, 10%);
129 | }
130 |
131 | .scroll-bar .increment-button,.scroll-bar .decrement-button {
132 | -fx-background-color:derive(black, 5%);
133 | -fx-padding: 5;
134 | }
135 |
136 | .scroll-bar .increment-button:hover,.scroll-bar .decrement-button:hover {
137 | -fx-background-color:derive(black, 10%);
138 | -fx-padding: 5;
139 | }
140 |
141 | .scroll-bar .corner {
142 | -fx-background-color:transparent;
143 | }
144 |
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/fireworks/folder-closed-32.fw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/fireworks/folder-closed-32.fw.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/fireworks/folder-closed-plus-32.fw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/fireworks/folder-closed-plus-32.fw.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/fireworks/folder-closed-unknown-xl-32.fw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/fireworks/folder-closed-unknown-xl-32.fw.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/fireworks/folder-closed-xl-32.fw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/fireworks/folder-closed-xl-32.fw.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/fireworks/folder-empty-32.fw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/fireworks/folder-empty-32.fw.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/fireworks/folder-file-open-32.fw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/fireworks/folder-file-open-32.fw.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/fireworks/folder-open-32.fw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/fireworks/folder-open-32.fw.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/fireworks/host-computer-32.fw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/fireworks/host-computer-32.fw.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/fireworks/windows-drive-32.fw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/fireworks/windows-drive-32.fw.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/fireworks/windows-drive-empty-32.fw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/fireworks/windows-drive-empty-32.fw.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/fireworks/windows-drive-plus-32.fw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/fireworks/windows-drive-plus-32.fw.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/fireworks/windows-drive-xl-32.fw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/fireworks/windows-drive-xl-32.fw.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/icons/folder-closed-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/icons/folder-closed-32.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/icons/folder-closed-plus-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/icons/folder-closed-plus-32.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/icons/folder-closed-unknown-xl-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/icons/folder-closed-unknown-xl-32.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/icons/folder-closed-xl-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/icons/folder-closed-xl-32.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/icons/folder-empty-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/icons/folder-empty-32.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/icons/folder-file-open-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/icons/folder-file-open-32.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/icons/folder-open-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/icons/folder-open-32.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/icons/host-computer-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/icons/host-computer-32.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/icons/windows-drive-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/icons/windows-drive-32.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/icons/windows-drive-empty-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/icons/windows-drive-empty-32.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/icons/windows-drive-plus-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/icons/windows-drive-plus-32.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/icons/windows-drive-xl-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/dirchooser/icons/windows-drive-xl-32.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/FileChooserDark.css:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2019 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 |
21 | .button {
22 | -fx-font-size: 13px;
23 | -fx-font-weight: bold;
24 | }
25 |
26 | .progress-indicator {
27 | -fx-text-fill: white;
28 | }
29 |
30 | .progress-bar .track{
31 | -fx-accent: #ffa700;
32 | -fx-background-color: black;
33 | -fx-background-insets: 1;
34 | -fx-background-radius: 0, 0, 0, 0;
35 | }
36 |
37 | .progress-bar .bar {
38 | -fx-accent: #ffa700;
39 | -fx-background-color: #ffa700;
40 | -fx-background-insets: 1, 0, 1, 0;
41 | -fx-background-radius: 0, 0, 0, 0;
42 | }
43 |
44 | .menu-button {
45 | -fx-font-size: 13px;
46 | -fx-font-weight: bold;
47 | }
48 |
49 | .list-view {
50 | -fx-blend-mode: screen;
51 | -fx-focus-color: transparent;
52 | -fx-faint-focus-color:transparent;
53 | }
54 |
55 | .list-cell:filled:selected:focused, .list-cell:filled:selected {
56 | -fx-background-color: #ffa700;
57 | /* -fx-text-fill: black; */
58 | }
59 |
60 | .list-cell:filled:hover {
61 | -fx-background-color: #212121;
62 | -fx-text-fill: black;
63 | }
64 |
65 | .text-field {
66 | -fx-blend-mode: screen;
67 | -fx-font-size: 13px;
68 | -fx-font-weight: bold;
69 | -fx-prompt-text-fill: black;
70 |
71 | -fx-focus-color : transparent;
72 | -fx-faint-focus-color : transparent;
73 | -fx-highlight-fill: #ffa700;
74 | -fx-highlight-text-fill: black;
75 | }
76 |
77 | .counter-label {
78 | -fx-font-size: 13px;
79 | -fx-font-weight: bold;
80 | -fx-text-fill: black;
81 | }
82 |
83 | .split-menu-button {
84 | -fx-font-size: 13px;
85 | -fx-font-weight: bold;
86 | }
87 |
88 | .filter-icon {
89 | -fx-fill: rgba(255,167,0,0.53);
90 | -fx-stroke-width: 1px;
91 | -fx-stroke: black;
92 | }
93 |
94 | .file-icon {
95 | -fx-background-color: transparent;
96 | -fx-effect: dropshadow( three-pass-box, rgba(0,0,0,0.8), 4, 0.0, 1, 1);
97 | -fx-padding: 10px;
98 | }
99 |
100 | .file-icon-pane {
101 | -fx-background-color: transparent;
102 | }
103 |
104 | .file-icon-label {
105 | -fx-font-size: 13px;
106 | -fx-font-weight: bold;
107 | }
108 |
109 | .root {
110 | -fx-base: rgb(50, 50, 50);
111 | -fx-background: rgb(50, 50, 50);
112 | -fx-control-inner-background: rgb(50, 50, 50);
113 |
114 | -fx-accent: transparent;
115 | /* -fx-focus-color: #ffa700;
116 | -fx-faint-focus-color: #ffa70066; */
117 |
118 | -fx-focus-color: transparent;
119 | -fx-faint-focus-color:transparent;
120 | }
121 |
122 | .tool-bar-icon {
123 | -fx-fill: #ffa700;
124 | -fx-highlight-text-fill: #000000;
125 | }
126 |
127 | .menu-item {
128 | /* -fx-accent: #ffa700; */
129 | -fx-accent: rgba(255,167,0,0.8);
130 | -fx-fill: #ffa700;
131 | }
132 |
133 | .menu-item-icon {
134 | -fx-fill: #ffa700;
135 | }
136 |
137 | .scroll-bar .thumb {
138 | -fx-background-insets: 2, 0, 0;
139 | -fx-background-color:derive(black, 5%);
140 | }
141 |
142 | .scroll-bar .thumb:hover {
143 | -fx-background-color:derive(black, 10%);
144 | }
145 |
146 | .scroll-bar .increment-button,.scroll-bar .decrement-button {
147 | -fx-background-color:derive(black, 5%);
148 | -fx-padding: 5;
149 | }
150 |
151 | .scroll-bar .increment-button:hover,.scroll-bar .decrement-button:hover {
152 | -fx-background-color:derive(black, 10%);
153 | -fx-padding: 5;
154 | }
155 |
156 | .scroll-bar .corner {
157 | -fx-background-color:transparent;
158 | }
159 |
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/FileChooserModena.css:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2024 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 |
21 |
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/FileChooserViewDark.css:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2019 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 |
21 | .button {
22 | -fx-font-size: 13px;
23 | -fx-font-weight: bold;
24 | }
25 |
26 | .progress-indicator {
27 | -fx-text-fill: white;
28 | }
29 |
30 | .progress-bar .track{
31 | -fx-accent: #ffa700;
32 | -fx-background-color: black;
33 | -fx-background-insets: 1;
34 | -fx-background-radius: 0, 0, 0, 0;
35 | }
36 |
37 | .progress-bar .bar {
38 | -fx-accent: #ffa700;
39 | -fx-background-color: #ffa700;
40 | -fx-background-insets: 1, 0, 1, 0;
41 | -fx-background-radius: 0, 0, 0, 0;
42 | }
43 |
44 | .menu-button {
45 | -fx-font-size: 13px;
46 | -fx-font-weight: bold;
47 | }
48 |
49 | .list-view {
50 | -fx-blend-mode: screen;
51 | -fx-focus-color: transparent;
52 | -fx-faint-focus-color:transparent;
53 | }
54 |
55 | .list-cell:filled:selected:focused, .list-cell:filled:selected {
56 | -fx-background-color: #ffa700;
57 | /* -fx-text-fill: black; */
58 | }
59 |
60 | .list-cell:filled:hover {
61 | -fx-background-color: #212121;
62 | -fx-text-fill: black;
63 | }
64 |
65 | .text-field {
66 | -fx-blend-mode: screen;
67 | -fx-font-size: 13px;
68 | -fx-font-weight: bold;
69 | -fx-prompt-text-fill: black;
70 |
71 | -fx-focus-color : transparent;
72 | -fx-faint-focus-color : transparent;
73 | -fx-highlight-fill: #ffa700;
74 | -fx-highlight-text-fill: black;
75 | }
76 |
77 | .counter-label {
78 | -fx-font-size: 13px;
79 | -fx-font-weight: bold;
80 | -fx-text-fill: black;
81 | }
82 |
83 | .split-menu-button {
84 | -fx-font-size: 13px;
85 | -fx-font-weight: bold;
86 | }
87 |
88 | .filter-icon {
89 | -fx-fill: rgba(255,167,0,0.53);
90 | -fx-stroke-width: 1px;
91 | -fx-stroke: black;
92 | }
93 |
94 | .file-icon {
95 | -fx-background-color: transparent;
96 | -fx-effect: dropshadow( three-pass-box, rgba(0,0,0,0.8), 4, 0.0, 1, 1);
97 | -fx-padding: 10px;
98 | }
99 |
100 | .file-icon-pane {
101 | -fx-background-color: transparent;
102 | }
103 |
104 | .file-icon-label {
105 | -fx-font-size: 13px;
106 | -fx-font-weight: bold;
107 | }
108 |
109 | .root {
110 | -fx-base: rgb(50, 50, 50);
111 | -fx-background: rgb(50, 50, 50);
112 | -fx-control-inner-background: rgb(50, 50, 50);
113 |
114 | -fx-accent: transparent;
115 | /* -fx-focus-color: #ffa700;
116 | -fx-faint-focus-color: #ffa70066; */
117 |
118 | -fx-focus-color: transparent;
119 | -fx-faint-focus-color:transparent;
120 | }
121 |
122 | .tool-bar-icon {
123 | -fx-fill: #ffa700;
124 | -fx-highlight-text-fill: #000000;
125 | }
126 |
127 | .menu-item {
128 | /* -fx-accent: #ffa700; */
129 | -fx-accent: rgba(255,167,0,0.8);
130 | -fx-fill: #ffa700;
131 | }
132 |
133 | .menu-item-icon {
134 | -fx-fill: #ffa700;
135 | }
136 |
137 | .scroll-bar .thumb {
138 | -fx-background-insets: 2, 0, 0;
139 | -fx-background-color:derive(black, 5%);
140 | }
141 |
142 | .scroll-bar .thumb:hover {
143 | -fx-background-color:derive(black, 10%);
144 | }
145 |
146 | .scroll-bar .increment-button,.scroll-bar .decrement-button {
147 | -fx-background-color:derive(black, 5%);
148 | -fx-padding: 5;
149 | }
150 |
151 | .scroll-bar .increment-button:hover,.scroll-bar .decrement-button:hover {
152 | -fx-background-color:derive(black, 10%);
153 | -fx-padding: 5;
154 | }
155 |
156 | .scroll-bar .corner {
157 | -fx-background-color:transparent;
158 | }
159 |
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/copy-solid.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/file-alt.svg:
--------------------------------------------------------------------------------
1 |
2 |
57 |
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/filter.svg:
--------------------------------------------------------------------------------
1 |
2 |
57 |
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-csv.fw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-csv.fw.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-doc.fw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-doc.fw.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-docx.fw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-docx.fw.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-docx2.fw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-docx2.fw.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-docx3.fw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-docx3.fw.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-docx4.fw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-docx4.fw.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-icon-template.fw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-icon-template.fw.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-template.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-template.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-txt.fw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-txt.fw.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-xls.fw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-xls.fw.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-xlsx.fw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-xlsx.fw.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-xlsx3.fw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-xlsx3.fw.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-xlsx4.fw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-xlsx4.fw.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-xml.fw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/file-xml.fw.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/template.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/fireworks/template.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/folder-open.svg:
--------------------------------------------------------------------------------
1 |
2 |
58 |
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/icons/file-csv.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/icons/file-csv.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/icons/file-doc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/icons/file-doc.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/icons/file-docx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/icons/file-docx.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/icons/file-docx2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/icons/file-docx2.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/icons/file-docx3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/icons/file-docx3.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/icons/file-docx4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/icons/file-docx4.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/icons/file-txt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/icons/file-txt.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/icons/file-unknown.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/icons/file-unknown.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/icons/file-xls.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/icons/file-xls.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/icons/file-xlsx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/icons/file-xlsx.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/icons/file-xlsx3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/icons/file-xlsx3.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/icons/file-xlsx4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/icons/file-xlsx4.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/icons/file-xml.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/icons/file-xml.png
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/paste-solid.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/sort-alpha-down.svg:
--------------------------------------------------------------------------------
1 |
2 |
57 |
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/sort-alpha-up.svg:
--------------------------------------------------------------------------------
1 |
2 |
57 |
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/sort-time-down.svg:
--------------------------------------------------------------------------------
1 |
2 |
59 |
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/sort-time-up.svg:
--------------------------------------------------------------------------------
1 |
2 |
59 |
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/stop-circle.svg:
--------------------------------------------------------------------------------
1 |
2 |
57 |
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/stop.svg:
--------------------------------------------------------------------------------
1 |
2 |
57 |
--------------------------------------------------------------------------------
/filechooser/src/main/resources/net/raumzeitfalle/fx/filechooser/sync-alt.svg:
--------------------------------------------------------------------------------
1 |
2 |
57 |
--------------------------------------------------------------------------------
/filechooser/src/main/resources/swingfilechooser.properties:
--------------------------------------------------------------------------------
1 | use.javafx.platform.directory.chooser=false
--------------------------------------------------------------------------------
/pages/ConvenienceFunctions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/pages/ConvenienceFunctions.png
--------------------------------------------------------------------------------
/pages/DefaultLocationsExample.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/pages/DefaultLocationsExample.png
--------------------------------------------------------------------------------
/pages/OSX_JavaFX_Dialog.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/pages/OSX_JavaFX_Dialog.png
--------------------------------------------------------------------------------
/pages/OSX_JavaFX_Stage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/pages/OSX_JavaFX_Stage.png
--------------------------------------------------------------------------------
/pages/OSX_Swing_JFXPanel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/pages/OSX_Swing_JFXPanel.png
--------------------------------------------------------------------------------
/pages/PathFilterExample.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/pages/PathFilterExample.png
--------------------------------------------------------------------------------
/pages/SortingMenuExample.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/pages/SortingMenuExample.png
--------------------------------------------------------------------------------
/pages/Windows81_JavaFX_Stage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/pages/Windows81_JavaFX_Stage.png
--------------------------------------------------------------------------------
/pages/Windows81_Swing_Dialog_ProcessRunning.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/pages/Windows81_Swing_Dialog_ProcessRunning.png
--------------------------------------------------------------------------------
/pages/filechooser/FXML_and_ids.afdesign:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/pages/filechooser/FXML_and_ids.afdesign
--------------------------------------------------------------------------------
/pages/filechooser/FXML_and_ids.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oliver-Loeffler/FXFileChooser/0878e95415c91c43e75f1a01f96a83027a935e7b/pages/filechooser/FXML_and_ids.png
--------------------------------------------------------------------------------
/scenicView.properties:
--------------------------------------------------------------------------------
1 | #ScenicView properties
2 | #Mon Mar 12 08:18:22 CET 2018
3 | showDefaultProperties=true
4 | autoRefreshStyleSheets=false
5 | showSearchBar=true
6 | showBounds=true
7 | ignoreMouseTransparentNodes=true
8 | splitPaneDividerPosition=0.4400230680507497
9 | collapseControls=true
10 | showFilteredNodesInTree=true
11 | showCSSProperties=false
12 | showInvisibleNodes=false
13 | collapseContainerControls=false
14 | showNodesIdInTree=false
15 | registerShortcuts=true
16 | automaticScenegraphStructureRefreshing=true
17 | stageHeight=851.0
18 | stageWidth=867.0
19 | showBaseline=false
20 |
--------------------------------------------------------------------------------
/tests/TestData/SomeFiles/HorrbibleSpreadSheet.xls:
--------------------------------------------------------------------------------
1 | TestFile1.txt
--------------------------------------------------------------------------------
/tests/TestData/SomeFiles/JustNumbers.csv:
--------------------------------------------------------------------------------
1 | TestFile1.txt
--------------------------------------------------------------------------------
/tests/TestData/SomeFiles/NewerDocument.docx:
--------------------------------------------------------------------------------
1 | TestFile1.txt
--------------------------------------------------------------------------------
/tests/TestData/SomeFiles/OldDocument.doc:
--------------------------------------------------------------------------------
1 | TestFile1.txt
--------------------------------------------------------------------------------
/tests/TestData/SomeFiles/SupposedToBeXtensible.xml:
--------------------------------------------------------------------------------
1 | TestFile1.txt
--------------------------------------------------------------------------------
/tests/TestData/SomeFiles/TestFile1.txt:
--------------------------------------------------------------------------------
1 | TestFile1.txt
--------------------------------------------------------------------------------
/tests/TestData/SomeFiles/TestFile2.txt:
--------------------------------------------------------------------------------
1 | TestFile2.txt
--------------------------------------------------------------------------------
/tests/TestData/SomeFiles/TestFile3.txt:
--------------------------------------------------------------------------------
1 | TestFile3.txt
--------------------------------------------------------------------------------
/tests/TestData/SomeFiles/TestFile4.txt:
--------------------------------------------------------------------------------
1 | TestFile4.txt
--------------------------------------------------------------------------------
/tests/TestData/SomeFiles/TestFile5.txt:
--------------------------------------------------------------------------------
1 | TestFile5.txt
--------------------------------------------------------------------------------
/tests/TestData/SomeFiles/XtremeHorrbibleSpreadSheet.xlsx:
--------------------------------------------------------------------------------
1 | TestFile1.txt
--------------------------------------------------------------------------------
/tests/TestData/SomeFiles/anotherDir/TestFile2.txt:
--------------------------------------------------------------------------------
1 | TestFile2.txt
--------------------------------------------------------------------------------
/tests/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net.raumzeitfalle.fx
5 | fxfilechooser
6 | 0.0.12-SNAPSHOT
7 |
8 |
9 | 4.0.0
10 | tests
11 | jar
12 |
13 |
14 |
15 | net.raumzeitfalle.fx
16 | filechooser
17 | 0.0.12-SNAPSHOT
18 |
19 |
20 |
21 | org.awaitility
22 | awaitility
23 | ${awaitility.version}
24 | test
25 |
26 |
27 | org.junit.jupiter
28 | junit-jupiter
29 | ${junit.jupiter.version}
30 | test
31 |
32 |
33 | org.junit.jupiter
34 | junit-jupiter-params
35 | ${junit.jupiter.version}
36 |
37 |
38 | org.testfx
39 | testfx-core
40 | ${testfx.version}
41 | test
42 |
43 |
44 | org.testfx
45 | testfx-junit5
46 | ${testfx.version}
47 | test
48 |
49 |
50 | org.testfx
51 | openjfx-monocle
52 | ${testfx.monocle.version}
53 | test
54 |
55 |
56 |
57 |
58 |
59 |
60 | org.apache.maven.plugins
61 | maven-compiler-plugin
62 |
63 | ${java.version}
64 | ${java.version}
65 |
66 |
67 |
68 | org.apache.maven.plugins
69 | maven-surefire-plugin
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/tests/src/test/java/net/raumzeitfalle/fx/filechooser/FXFileChooserStage1Test.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2022 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
23 | import static org.junit.jupiter.api.Assertions.assertEquals;
24 | import static org.junit.jupiter.api.Assertions.assertNotNull;
25 |
26 | import java.awt.image.BufferedImage;
27 | import java.io.File;
28 | import java.io.IOException;
29 | import java.nio.file.Paths;
30 |
31 | import javax.imageio.ImageIO;
32 |
33 | import org.junit.jupiter.api.AfterEach;
34 | import org.junit.jupiter.api.Test;
35 | import org.testfx.framework.junit5.ApplicationTest;
36 |
37 | import javafx.embed.swing.SwingFXUtils;
38 | import javafx.scene.Parent;
39 | import javafx.stage.Stage;
40 |
41 |
42 | public class FXFileChooserStage1Test extends ApplicationTest {
43 |
44 | protected FXFileChooserStage stageUnderTest;
45 |
46 | @Override
47 | public void start(Stage stage) {
48 | stageUnderTest = FXFileChooserStage.create(Skin.DARK);
49 | stage = stageUnderTest;
50 | stage.show();
51 | }
52 |
53 | @AfterEach
54 | void closeStage() throws Exception {
55 | Invoke.andWait(() -> stageUnderTest.close());
56 | }
57 |
58 | @Test
59 | void that_defaults_for_filter_and_search_path_are_working() {
60 | assertDoesNotThrow(() -> lookup("#okButton").query());
61 | Parent root = stageUnderTest.getScene().getRoot();
62 | captureImage(root, "ScreenshotFXFileChooserStageDark.png");
63 |
64 | FileChooserModel model = stageUnderTest.getModel();
65 | assertEquals(1, model.getPathFilter().size());
66 | assertEquals("*.*", model.getPathFilter().get(0).getName());
67 | assertNotNull(model.getPathFilter().get(0).getPredicate());
68 | assertEquals(Paths.get("."), model.currentSearchPath().get());
69 | }
70 |
71 | protected void captureImage(Parent put, String filename) {
72 | BufferedImage bImage = SwingFXUtils.fromFXImage(capture(put).getImage(), null);
73 | try {
74 | ImageIO.write(bImage, "png", new File(filename));
75 | } catch (IOException e) {
76 | throw new RuntimeException(e);
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/tests/src/test/java/net/raumzeitfalle/fx/filechooser/FXFileChooserStage2Test.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2022 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import static org.junit.jupiter.api.Assertions.assertEquals;
23 | import static org.junit.jupiter.api.Assertions.assertFalse;
24 | import static org.junit.jupiter.api.Assertions.assertTrue;
25 |
26 | import org.junit.jupiter.api.Test;
27 | import org.testfx.framework.junit5.ApplicationTest;
28 |
29 | import javafx.stage.Stage;
30 |
31 | public class FXFileChooserStage2Test extends ApplicationTest {
32 |
33 | protected FXFileChooserStage stageUnderTest;
34 |
35 | @Override
36 | public void start(Stage stage) {
37 | stageUnderTest = FXFileChooserStage.create(Skin.DARK, PathFilter.create("only-text", p -> p.toString().endsWith(".txt")),
38 | PathFilter.create("only-html", p -> p.toString().endsWith(".html")));
39 | stage = stageUnderTest;
40 | }
41 |
42 | @Test
43 | void that_adding_multiple_custom_filters_works() {
44 | FileChooserModel model = stageUnderTest.getModel();
45 | assertEquals(2, model.getPathFilter().size());
46 |
47 | PathFilter first = model.getPathFilter().get(0);
48 | assertEquals("only-text", first.getName());
49 | assertTrue(first.getPredicate().test("my-special-file.txt"));
50 | assertFalse(first.getPredicate().test("my-other-file.html"));
51 |
52 | PathFilter second = model.getPathFilter().get(1);
53 | assertEquals("only-html", second.getName());
54 | assertFalse(second.getPredicate().test("my-special-file.txt"));
55 | assertTrue(second.getPredicate().test("my-other-file.html"));
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/tests/src/test/java/net/raumzeitfalle/fx/filechooser/FXFileChooserStage3Test.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2022 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import static org.junit.jupiter.api.Assertions.assertEquals;
23 | import static org.junit.jupiter.api.Assertions.assertTrue;
24 |
25 | import java.nio.file.Path;
26 | import java.util.List;
27 |
28 | import org.junit.jupiter.api.Test;
29 | import org.junit.jupiter.api.io.TempDir;
30 | import org.testfx.framework.junit5.ApplicationTest;
31 |
32 | import javafx.stage.Stage;
33 |
34 |
35 | public class FXFileChooserStage3Test extends ApplicationTest {
36 |
37 | @TempDir
38 | public static Path tempDir;
39 |
40 | protected FXFileChooserStage stageUnderTest;
41 |
42 | @Override
43 | public void start(Stage stage) {
44 | stageUnderTest = FXFileChooserStage.create(Skin.DARK, tempDir);
45 | stage = stageUnderTest;
46 | }
47 |
48 | @Test
49 | void that_pathfilter_defaults_are_used_when_configuring_only_directory() {
50 | FileChooserModel model = stageUnderTest.getModel();
51 | List filter = model.getPathFilter();
52 | assertEquals(1, filter.size());
53 | assertEquals("*.*", filter.get(0).getName());
54 | assertTrue(filter.get(0).getPredicate().test("anyThing"));
55 | assertTrue(filter.get(0).getPredicate().test("anyThing.else"));
56 | assertTrue(filter.get(0).getPredicate().test("anyThing.txt"));
57 | assertTrue(filter.get(0).getPredicate().test("*.*&%%"));
58 | assertEquals(tempDir, model.currentSearchPath().get());
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/tests/src/test/java/net/raumzeitfalle/fx/filechooser/FileChooserDarkTest.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2021 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
23 |
24 | import java.nio.file.Path;
25 | import java.nio.file.Paths;
26 |
27 | import org.junit.jupiter.api.AfterEach;
28 | import org.junit.jupiter.api.Test;
29 | import org.junit.jupiter.api.io.TempDir;
30 |
31 | import javafx.scene.Parent;
32 | import javafx.scene.input.MouseButton;
33 |
34 | class FileChooserDarkTest extends FileChooserTestBase {
35 |
36 | @TempDir
37 | public static Path emptyDirectory;
38 |
39 | public static Path withFiles = Paths.get("TestData/SomeFiles").toAbsolutePath();
40 |
41 | @Override
42 | protected PathFilter getPathFilter() {
43 | return PathFilter.acceptAllFiles("all files");
44 | }
45 |
46 | @Override
47 | protected Skin getSkin() {
48 | return Skin.DARK;
49 | }
50 |
51 | @Override
52 | protected Path getStartDirectory() {
53 | return emptyDirectory;
54 | }
55 |
56 | @AfterEach
57 | void closeStage() throws Exception {
58 | Invoke.andWait(() -> primaryStage.close());
59 | }
60 |
61 | /*
62 | * There seems to be an issue with TestFX when the FXML represents the root pane
63 | * of a control. If so, TestFX correctly approaches the positions of all nodes
64 | * but interaction such as click, write, press etc. is not working.
65 | *
66 | * See StackOverflow:
67 | * https://stackoverflow.com/questions/57051778/how-to-get-testfx-to-find-the-
68 | * roots-fxid-in-testing-the-root-is-a-custom-cont
69 | *
70 | * TODO: User Kleopatra asked for a minimal reproducible example, I think this
71 | * will be doable.
72 | */
73 |
74 | @Test
75 | void viewCanBeLoaded() {
76 | assertDoesNotThrow(() -> lookup("#okButton").query());
77 | clickOn("#refreshButton", MouseButton.PRIMARY);
78 | Parent root = primaryStage.getScene().getRoot();
79 | captureImage(root, "ScreenshotDarkTheme.png");
80 | }
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/tests/src/test/java/net/raumzeitfalle/fx/filechooser/FileChooserModelApplicationTest.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2019 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import static org.junit.jupiter.api.Assertions.assertEquals;
23 | import static org.junit.jupiter.api.Assertions.assertFalse;
24 | import static org.junit.jupiter.api.Assertions.assertTrue;
25 |
26 | import java.nio.file.Path;
27 | import java.nio.file.Paths;
28 | import java.util.concurrent.ExecutionException;
29 |
30 | import org.junit.jupiter.api.Test;
31 |
32 | class FileChooserModelApplicationTest extends FxTestTemplate {
33 |
34 | private FileChooserModel classUnderTest;
35 |
36 | private Path testRoot = Paths.get("./TestData/SomeFiles");
37 |
38 | private PathFilter txtFiles = PathFilter.forFileExtension("TXT", "txt");
39 |
40 | @Override
41 | public void init() throws Exception {
42 | classUnderTest = FileChooserModel.startingIn(testRoot);
43 | }
44 |
45 | @Test
46 | void performFilterOperation() throws InterruptedException, ExecutionException {
47 | assertEquals(testRoot.toAbsolutePath(), classUnderTest.currentSearchPath().get().toAbsolutePath(),
48 | "search path after initialization");
49 |
50 | sleep(500);
51 |
52 | assertEquals(11, classUnderTest.getFilteredPaths().size());
53 |
54 | // search all files with extension ".txt"
55 | classUnderTest.updateFilterCriterion(txtFiles, "");
56 | assertEquals(5, classUnderTest.getFilteredPaths().size());
57 |
58 | // search all files with extension ".txt" and string "File3" in name
59 | classUnderTest.updateFilterCriterion(txtFiles, "File3");
60 | assertEquals(1, classUnderTest.getFilteredPaths().size());
61 |
62 | // search all files with extension ".txt" and string "File3" in name
63 | classUnderTest.updateFilterCriterion(txtFiles, "File3");
64 | assertEquals(1, classUnderTest.getFilteredPaths().size());
65 |
66 | PathFilter allFiles = PathFilter.create(p -> true);
67 |
68 | // search all files with a horrible name
69 | classUnderTest.updateFilterCriterion(allFiles, "Horrbible");
70 | assertEquals(2, classUnderTest.getFilteredPaths().size());
71 |
72 | // no selection yet performed
73 | assertTrue(classUnderTest.invalidSelectionProperty().get());
74 |
75 | // now mimic a selection by user
76 | IndexedPath selection = classUnderTest.getFilteredPaths().get(0);
77 | classUnderTest.setSelectedFile(selection);
78 |
79 | assertFalse(classUnderTest.invalidSelectionProperty().get());
80 |
81 | Path selectedFile = classUnderTest.getSelectedFile();
82 | assertEquals(selection.asPath(testRoot).getFileName(), selectedFile.getFileName());
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/tests/src/test/java/net/raumzeitfalle/fx/filechooser/FileChooserModelFactoryMethodsFxTest.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2019 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import static org.junit.jupiter.api.Assertions.assertEquals;
23 | import static org.junit.jupiter.api.Assertions.assertNotEquals;
24 |
25 | import java.nio.file.Path;
26 | import java.nio.file.Paths;
27 | import java.util.concurrent.ExecutionException;
28 |
29 | import org.junit.jupiter.api.Test;
30 |
31 | class FileChooserModelFactoryMethodsFxTest extends FxTestTemplate {
32 |
33 | private FileChooserModel classUnderTest;
34 |
35 | private Path testRoot = Paths.get("./TestData/SomeFiles");
36 |
37 | @Override
38 | public void init() throws Exception {
39 | classUnderTest = FileChooserModel.startingInUsersHome();
40 | }
41 |
42 | @Test
43 | void startingInUsersHome() {
44 | Path searchPath = classUnderTest.currentSearchPath().get();
45 | Path usersHome = Paths.get(System.getProperty("user.home"));
46 |
47 | assertEquals(usersHome.toAbsolutePath(), searchPath.toAbsolutePath());
48 | }
49 |
50 | @Test
51 | void changingDirectory_updateFilesIn() throws InterruptedException, ExecutionException {
52 | assertNotEquals(testRoot.isAbsolute(),
53 | classUnderTest.currentSearchPath()
54 | .get()
55 | .toAbsolutePath(),
56 | "search path before directory change");
57 |
58 | // Consider moving the service into the controller out of the model
59 | Invoke.andWait(() -> classUnderTest.getUpdateService().restartIn(testRoot));
60 |
61 | assertEquals(testRoot.toAbsolutePath(),
62 | classUnderTest.currentSearchPath()
63 | .get()
64 | .toAbsolutePath(),
65 | "search path after directory change");
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/tests/src/test/java/net/raumzeitfalle/fx/filechooser/FileChooserModenaTest.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2021 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
23 |
24 | import java.nio.file.*;
25 |
26 | import org.junit.jupiter.api.AfterEach;
27 | import org.junit.jupiter.api.Test;
28 | import org.junit.jupiter.api.io.TempDir;
29 |
30 | import javafx.scene.Parent;
31 |
32 | class FileChooserModenaTest extends FileChooserTestBase {
33 |
34 | @TempDir
35 | public static Path emptyDirectory;
36 |
37 | public static Path withFiles = Paths.get("TestData/SomeFiles").toAbsolutePath();
38 |
39 | @Override
40 | protected PathFilter getPathFilter() {
41 | return PathFilter.acceptAllFiles("all files");
42 | }
43 |
44 | @Override
45 | protected Skin getSkin() {
46 | return Skin.MODENA;
47 | }
48 |
49 | @Override
50 | protected Path getStartDirectory() {
51 | return emptyDirectory;
52 | }
53 |
54 | @AfterEach
55 | void closeStage() throws Exception {
56 | Invoke.andWait(() -> primaryStage.close());
57 | }
58 |
59 | /*
60 | * There seems to be an issue with TestFX when the FXML represents the root pane
61 | * of a control. If so, TestFX correctly approaches the positions of all nodes
62 | * but interaction such as click, write, press etc. is not working.
63 | *
64 | * See StackOverflow:
65 | * https://stackoverflow.com/questions/57051778/how-to-get-testfx-to-find-the-
66 | * roots-fxid-in-testing-the-root-is-a-custom-cont
67 | *
68 | * TODO: User Kleopatra asked for a minimal reproducible example, I think this
69 | * will be doable.
70 | */
71 | @Test
72 | void viewCanBeLoaded() {
73 | assertDoesNotThrow(() -> lookup("#okButton").query());
74 | Parent root = primaryStage.getScene().getRoot();
75 | captureImage(root, "ScreenshotModenaTheme.png");
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/tests/src/test/java/net/raumzeitfalle/fx/filechooser/FileChooserTestBase.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2021 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import java.awt.image.BufferedImage;
23 | import java.io.File;
24 | import java.io.IOException;
25 | import java.nio.file.Path;
26 |
27 | import javax.imageio.ImageIO;
28 |
29 | import org.testfx.framework.junit5.ApplicationTest;
30 |
31 | import javafx.embed.swing.SwingFXUtils;
32 | import javafx.scene.Parent;
33 | import javafx.scene.Scene;
34 | import javafx.stage.Stage;
35 |
36 | abstract class FileChooserTestBase extends ApplicationTest {
37 |
38 | protected Stage primaryStage;
39 |
40 | protected abstract PathFilter getPathFilter();
41 |
42 | protected abstract Skin getSkin();
43 |
44 | protected abstract Path getStartDirectory();
45 |
46 | @Override
47 | public void start(Stage stage) {
48 | primaryStage = stage;
49 | FileChooserModel model = FileChooserModel.startingIn(getStartDirectory(), getPathFilter());
50 | FXDirectoryChooser dirChooser = FXDirectoryChooser.createIn(model.currentSearchPath(), () -> stage.getOwner());
51 | Parent view = new FileChooser(dirChooser, () -> stage.close(), model, getSkin(), FileChooserViewOption.STAGE);
52 | Scene scene = new Scene(view, 700, 500);
53 | stage.setScene(scene);
54 | stage.show();
55 | }
56 |
57 | protected void captureImage(Parent put, String filename) {
58 | BufferedImage bImage = SwingFXUtils.fromFXImage(capture(put).getImage(), null);
59 | try {
60 | ImageIO.write(bImage, "png", new File(filename));
61 | } catch (IOException e) {
62 | throw new RuntimeException(e);
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/tests/src/test/java/net/raumzeitfalle/fx/filechooser/FilesListCellTest.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2021 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import static org.junit.jupiter.api.Assertions.assertEquals;
23 | import static org.junit.jupiter.api.Assertions.assertNotNull;
24 | import static org.junit.jupiter.api.Assertions.assertNull;
25 | import static org.junit.jupiter.api.Assertions.assertTrue;
26 |
27 | import java.nio.file.Paths;
28 | import java.util.HashMap;
29 | import java.util.Map;
30 |
31 | import org.junit.jupiter.api.Test;
32 |
33 | import javafx.scene.Node;
34 | import javafx.scene.control.Labeled;
35 | import javafx.scene.layout.Pane;
36 |
37 | class FilesListCellTest extends FxTestTemplate {
38 |
39 | private FilesListCell controlUnderTest;
40 |
41 | @Test
42 | void creationWithoutUpdate() {
43 | controlUnderTest = new FilesListCell();
44 | assertNotNull(controlUnderTest);
45 | assertNull(controlUnderTest.getText());
46 | assertNull(controlUnderTest.getGraphic());
47 | assertTrue(controlUnderTest.isVisible());
48 | }
49 |
50 | @Test
51 | void updateWithValidItem() {
52 | IndexedPath path = IndexedPath.valueOf(Paths.get("TestData/SomeFiles/HorrbibleSpreadSheet.xls"));
53 |
54 | controlUnderTest = new FilesListCell();
55 | controlUnderTest.updateItem(path, false);
56 |
57 | assertNull(controlUnderTest.getText());
58 | assertTrue(controlUnderTest.isVisible());
59 |
60 | Pane subView = (Pane) controlUnderTest.getGraphic();
61 | assertNotNull(subView);
62 |
63 | Map expectedNodes = new HashMap<>();
64 | for (Node n : subView.getChildrenUnmodifiable()) {
65 | if (n.getId().startsWith("fileListCell-")) {
66 | expectedNodes.put(n.getId(), n);
67 | }
68 | }
69 |
70 | assertNotNull(expectedNodes.get("fileListCell-fileTypeIcon"));
71 |
72 | assertNotNull(expectedNodes.get("fileListCell-fileName"));
73 | assertTrue(expectedNodes.get("fileListCell-fileName") instanceof Labeled);
74 | assertEquals("HorrbibleSpreadSheet.xls", ((Labeled) expectedNodes.get("fileListCell-fileName")).getText());
75 |
76 | assertNotNull(expectedNodes.get("fileListCell-fileDate"));
77 | assertTrue(expectedNodes.get("fileListCell-fileDate") instanceof Labeled);
78 |
79 | String expectedPattern = "\\d{4}-\\d{2}-\\d{2} - \\d{2}:\\d{2}:\\d{2}";
80 | String labelText = ((Labeled) expectedNodes.get("fileListCell-fileDate")).getText();
81 |
82 | assertTrue(labelText.matches(expectedPattern));
83 | }
84 |
85 | @Test
86 | void updateWithNullItem() {
87 |
88 | controlUnderTest = new FilesListCell();
89 | controlUnderTest.updateItem(null, false);
90 |
91 | assertNotNull(controlUnderTest);
92 | assertNull(controlUnderTest.getText());
93 | assertNull(controlUnderTest.getGraphic());
94 | assertTrue(controlUnderTest.isVisible());
95 | }
96 |
97 | }
98 |
--------------------------------------------------------------------------------
/tests/src/test/java/net/raumzeitfalle/fx/filechooser/FxTestTemplate.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2021 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import org.testfx.framework.junit5.ApplicationTest;
23 |
24 | import javafx.scene.input.KeyCode;
25 | import javafx.stage.Stage;
26 |
27 | abstract class FxTestTemplate extends ApplicationTest {
28 | protected Stage primaryStage = null;
29 |
30 | @Override
31 | public void start(Stage stage) throws Exception {
32 | /* please override when needed */
33 | }
34 |
35 | public void hitKey(KeyCode keyCode) {
36 | press(keyCode).release(keyCode);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/tests/src/test/java/net/raumzeitfalle/fx/filechooser/IndexedPathTest.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2022 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import static org.junit.jupiter.api.Assertions.*;
23 |
24 | import java.nio.file.Path;
25 | import java.nio.file.Paths;
26 | import java.nio.file.attribute.FileTime;
27 |
28 | import org.junit.jupiter.api.Test;
29 |
30 | class IndexedPathTest {
31 |
32 | private IndexedPath classUnderTest;
33 |
34 | @Test
35 | void asPath() {
36 | Path source = Paths.get("TestData/SomeFiles/HorrbibleSpreadSheet.xls").toAbsolutePath();
37 | classUnderTest = IndexedPath.valueOf(source);
38 |
39 | assertEquals(source,
40 | classUnderTest.asPath(Paths.get("TestData/SomeFiles/").toAbsolutePath()));
41 | }
42 |
43 | @Test
44 | void stringRepresentation() {
45 | Path source = Paths.get("TestData/SomeFiles/HorrbibleSpreadSheet.xls").toAbsolutePath();
46 | classUnderTest = IndexedPath.valueOf(source);
47 |
48 | assertEquals(source.getFileName().toString(), classUnderTest.toString());
49 | }
50 |
51 | @Test
52 | void getTimestamp() {
53 | Path source = Paths.get("TestData/SomeFiles/HorrbibleSpreadSheet.xls").toAbsolutePath();
54 | classUnderTest = IndexedPath.valueOf(source);
55 |
56 | FileTime timestamp = classUnderTest.getTimestamp();
57 |
58 | assertNotNull(timestamp);
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/tests/src/test/java/net/raumzeitfalle/fx/filechooser/PathComparatorTest.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2022 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import static org.junit.jupiter.api.Assertions.assertEquals;
23 |
24 | import java.io.IOException;
25 | import java.nio.file.Path;
26 | import java.nio.file.Paths;
27 | import java.nio.file.attribute.FileTime;
28 | import java.time.Instant;
29 | import java.util.Arrays;
30 | import java.util.Comparator;
31 | import java.util.List;
32 | import java.util.stream.Collectors;
33 |
34 | import org.junit.jupiter.api.Test;
35 |
36 | class PathComparatorTest {
37 |
38 | private final Path b = Paths.get("byFarOldestFile.txt");
39 |
40 | private final Path a = Paths.get("aNewFile.txt");
41 |
42 | private final Path c = Paths.get("crazyLargeFile.cfg");
43 |
44 | private Comparator comparatorUnderTest;
45 |
46 | @Test
47 | void byName_ascending() {
48 | comparatorUnderTest = PathComparator.byName();
49 |
50 | List sorted = sortUsing(comparatorUnderTest, a, b, c);
51 |
52 | assertEquals(a, sorted.get(0));
53 | assertEquals(b, sorted.get(1));
54 | assertEquals(c, sorted.get(2));
55 | }
56 |
57 | @Test
58 | void byName_descending() {
59 | comparatorUnderTest = PathComparator.byName().reversed();
60 |
61 | List sorted = sortUsing(comparatorUnderTest, a, b, c);
62 |
63 | assertEquals(a, sorted.get(2));
64 | assertEquals(b, sorted.get(1));
65 | assertEquals(c, sorted.get(0));
66 | }
67 |
68 | @Test
69 | void byTimestamp_ascending() throws IOException {
70 | comparatorUnderTest = PathComparator.byTimestamp();
71 | Path fileA = Paths.get("./TestData/A-oldest.txt");
72 | Path fileB = Paths.get("./TestData/B-latest.txt");
73 |
74 | IndexedPath a = new IndexedPath(fileA, FileTime.from(Instant.now().minusSeconds(100)));
75 | IndexedPath b = new IndexedPath(fileB, FileTime.from(Instant.now()));
76 |
77 | List paths = sortUsing(comparatorUnderTest, a, b);
78 |
79 | assertEquals(fileA.getFileName(), paths.get(0));
80 | assertEquals(fileB.getFileName(), paths.get(1));
81 | }
82 |
83 | private List sortUsing(Comparator comparatorUnderTest, Path... file) {
84 | return Arrays.stream(file).map(IndexedPath::valueOf)
85 | .sorted(comparatorUnderTest)
86 | .map(a -> Paths.get(a.toString()))
87 | .collect(Collectors.toList());
88 | }
89 |
90 | private List sortUsing(Comparator comparatorUnderTest, IndexedPath... file) {
91 | return Arrays.stream(file)
92 | .sorted(comparatorUnderTest)
93 | .map(a -> Paths.get(a.toString()))
94 | .collect(Collectors.toList());
95 | }
96 |
97 | }
98 |
--------------------------------------------------------------------------------
/tests/src/test/java/net/raumzeitfalle/fx/filechooser/RefreshBufferTest.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2021 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import static org.junit.jupiter.api.Assertions.assertEquals;
23 |
24 | import org.junit.jupiter.params.ParameterizedTest;
25 | import org.junit.jupiter.params.provider.CsvSource;
26 |
27 | class RefreshBufferTest {
28 |
29 | @ParameterizedTest
30 | @CsvSource({
31 | "1, 10",
32 | "5, 10",
33 | "100, 10",
34 | "1001, 20",
35 | "5000, 20",
36 | "5001, 50",
37 | "15000, 50",
38 | "15001, 100",
39 | "50000, 100",
40 | "50001, 200",
41 | "100000, 200",
42 | "100001, 500",
43 | "600001, 1000", })
44 | void cacheSize(Integer items, Integer expectedBufferSize) {
45 | int bufferSize = RefreshBuffer.determineBufferSize(items);
46 | assertEquals(bufferSize, expectedBufferSize);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/tests/src/test/java/net/raumzeitfalle/fx/filechooser/ServiceWorkerStateListener.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2021 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser;
21 |
22 | import java.util.concurrent.CompletableFuture;
23 | import java.util.function.Supplier;
24 |
25 | import javafx.beans.value.ChangeListener;
26 | import javafx.beans.value.ObservableValue;
27 | import javafx.concurrent.Service;
28 | import javafx.concurrent.Worker;
29 | import javafx.concurrent.Worker.State;
30 |
31 | class ServiceWorkerStateListener implements ChangeListener {
32 |
33 | private final CompletableFuture> serviceTestResult = new CompletableFuture<>();
34 |
35 | private final Supplier valueSource;
36 |
37 | public static ServiceWorkerStateListener with(Service serviceUnderTest) {
38 |
39 | ServiceWorkerStateListener listener = new ServiceWorkerStateListener<>(serviceUnderTest);
40 | serviceUnderTest.stateProperty().addListener(listener);
41 |
42 | return listener;
43 | }
44 |
45 | public ServiceWorkerStateListener(Service serviceUnderTest) {
46 | this(() -> serviceUnderTest.getValue());
47 | }
48 |
49 | public ServiceWorkerStateListener(Supplier valueSource) {
50 | this.valueSource = valueSource;
51 | }
52 |
53 | @Override
54 | public void changed(ObservableValue extends State> observable, State oldValue, State newValue) {
55 | if (newValue == Worker.State.SUCCEEDED) {
56 | serviceTestResult.complete(new ServiceExecResult(newValue, valueSource.get()));
57 | }
58 |
59 | if (newValue == Worker.State.CANCELLED) {
60 | serviceTestResult.complete(new ServiceExecResult(newValue, valueSource.get()));
61 | }
62 |
63 | if (newValue == Worker.State.FAILED) {
64 | serviceTestResult.complete(new ServiceExecResult(newValue, valueSource.get()));
65 | }
66 |
67 | }
68 |
69 | public CompletableFuture> getServiceResult() {
70 | return serviceTestResult;
71 | }
72 |
73 | static class ServiceExecResult {
74 |
75 | private final Worker.State serviceState;
76 |
77 | private final R result;
78 |
79 | public ServiceExecResult(Worker.State serviceState, R result) {
80 | this.serviceState = serviceState;
81 | this.result = result;
82 | }
83 |
84 | public Worker.State getServiceState() {
85 | return serviceState;
86 | }
87 |
88 | public R getResult() {
89 | return result;
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/tests/src/test/java/net/raumzeitfalle/fx/filechooser/locations/LocationsTest.java:
--------------------------------------------------------------------------------
1 | /*-
2 | * #%L
3 | * FXFileChooser
4 | * %%
5 | * Copyright (C) 2017 - 2021 Oliver Loeffler, Raumzeitfalle.net
6 | * %%
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * #L%
19 | */
20 | package net.raumzeitfalle.fx.filechooser.locations;
21 |
22 | import static org.junit.jupiter.api.Assertions.assertAll;
23 | import static org.junit.jupiter.api.Assertions.assertEquals;
24 | import static org.junit.jupiter.api.Assertions.assertThrows;
25 | import static org.junit.jupiter.api.Assertions.assertTrue;
26 |
27 | import java.nio.file.Path;
28 | import java.nio.file.Paths;
29 |
30 | import org.junit.jupiter.api.Test;
31 |
32 | class LocationsTest {
33 |
34 | @Test
35 | void at_with_null_argument() {
36 | Throwable t = assertThrows(NullPointerException.class, () -> Locations.at(null));
37 | assertEquals("path must not be null", t.getMessage());
38 | }
39 |
40 | @Test
41 | void at_with_file_having_a_parent() {
42 | Path path = Paths.get("TestData/SomeFiles/TestFile1.txt");
43 | Location location = Locations.at(path);
44 |
45 | assertAll(() -> assertEquals("TestData/SomeFiles", location.getName().replace("\\", "/"), "name"),
46 | () -> assertTrue(location.exists(), "exist"),
47 | () -> assertEquals(path.getParent(), location.getPath(), "path"));
48 | }
49 |
50 | @Test
51 | void at_with_directory_having_a_parent() {
52 | Path path = Paths.get("TestData/SomeFiles/");
53 | Location location = Locations.at(path);
54 |
55 | assertAll(() -> assertEquals("TestData/SomeFiles", location.getName().replace("\\", "/"), "name"),
56 | () -> assertTrue(location.exists(), "exist"),
57 | () -> assertEquals(path, location.getPath(), "path"));
58 | }
59 | }
60 |
--------------------------------------------------------------------------------