MCPcopy
hub / github.com/arduino/Arduino / handleOpenPrompt

Method handleOpenPrompt

app/src/processing/app/Base.java:819–848  ·  view source on GitHub ↗

Prompt for a sketch to open, and open it in a new window. @throws Exception

()

Source from the content-addressed store, hash-verified

817 * @throws Exception
818 */
819 public void handleOpenPrompt() throws Exception {
820 // get the frontmost window frame for placing file dialog
821 FileDialog fd = new FileDialog(activeEditor, tr("Open an Arduino sketch..."), FileDialog.LOAD);
822 File lastFolder = new File(PreferencesData.get("last.folder", BaseNoGui.getSketchbookFolder().getAbsolutePath()));
823 if (lastFolder.exists() && lastFolder.isFile()) {
824 lastFolder = lastFolder.getParentFile();
825 }
826 fd.setDirectory(lastFolder.getAbsolutePath());
827
828 // Only show .pde files as eligible bachelors
829 fd.setFilenameFilter(new FilenameFilter() {
830 public boolean accept(File dir, String name) {
831 return name.toLowerCase().endsWith(".ino")
832 || name.toLowerCase().endsWith(".pde");
833 }
834 });
835
836 fd.setVisible(true);
837
838 String directory = fd.getDirectory();
839 String filename = fd.getFile();
840
841 // User canceled selection
842 if (filename == null) return;
843
844 File inputFile = new File(directory, filename);
845
846 PreferencesData.set("last.folder", inputFile.getAbsolutePath());
847 handleOpen(inputFile);
848 }
849
850
851 /**

Callers 2

actionPerformedMethod · 0.95
buildFileMenuMethod · 0.80

Calls 8

getMethod · 0.95
getSketchbookFolderMethod · 0.95
setMethod · 0.95
handleOpenMethod · 0.95
trMethod · 0.80
setVisibleMethod · 0.80
existsMethod · 0.45
getFileMethod · 0.45

Tested by

no test coverage detected