MCPcopy Index your code
hub / github.com/benfry/processing4 / selectFolderImpl

Method selectFolderImpl

core/src/processing/awt/ShimAWT.java:874–908  ·  view source on GitHub ↗
(final String prompt,
                                      final String callbackMethod,
                                      final File defaultSelection,
                                      final Object callbackObject,
                                      final Frame parentFrame)

Source from the content-addressed store, hash-verified

872
873
874 static public void selectFolderImpl(final String prompt,
875 final String callbackMethod,
876 final File defaultSelection,
877 final Object callbackObject,
878 final Frame parentFrame) {
879 File selectedFile = null;
880 if (PApplet.platform == PConstants.MACOS && PApplet.useNativeSelect) {
881 FileDialog fileDialog =
882 new FileDialog(parentFrame, prompt, FileDialog.LOAD);
883 if (defaultSelection != null) {
884 fileDialog.setDirectory(defaultSelection.getAbsolutePath());
885 }
886 System.setProperty("apple.awt.fileDialogForDirectories", "true");
887 fileDialog.setVisible(true);
888 System.setProperty("apple.awt.fileDialogForDirectories", "false");
889 String filename = fileDialog.getFile();
890 if (filename != null) {
891 selectedFile = new File(fileDialog.getDirectory(), fileDialog.getFile());
892 }
893 } else {
894 checkLookAndFeel();
895 JFileChooser fileChooser = new JFileChooser();
896 fileChooser.setDialogTitle(prompt);
897 fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
898 if (defaultSelection != null) {
899 fileChooser.setCurrentDirectory(defaultSelection);
900 }
901
902 int result = fileChooser.showOpenDialog(parentFrame);
903 if (result == JFileChooser.APPROVE_OPTION) {
904 selectedFile = fileChooser.getSelectedFile();
905 }
906 }
907 PApplet.selectCallback(selectedFile, callbackMethod, callbackObject);
908 }
909
910
911 static private boolean lookAndFeelCheck;

Callers 2

selectFolderMethod · 0.95
selectFolderMethod · 0.95

Calls 5

checkLookAndFeelMethod · 0.95
selectCallbackMethod · 0.95
getFileMethod · 0.80
setPropertyMethod · 0.65
setVisibleMethod · 0.65

Tested by

no test coverage detected