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

Method handleAddFile

app/src/processing/app/Sketch.java:1359–1392  ·  view source on GitHub ↗

Prompt the user for a new file to the sketch, then call the other addFile() function to actually add it.

()

Source from the content-addressed store, hash-verified

1357 * other addFile() function to actually add it.
1358 */
1359 public void handleAddFile() {
1360 // make sure the user didn't hide the sketch folder
1361 ensureExistence();
1362
1363 // if read-only, give an error
1364 if (isReadOnly()) {
1365 // if the files are read-only, need to first do a "save as".
1366 Messages.showMessage(Language.text("add_file.messages.is_read_only"),
1367 Language.text("add_file.messages.is_read_only.description"));
1368 return;
1369 }
1370
1371 // get a dialog, select a file to add to the sketch
1372 String prompt = Language.text("file");
1373 //FileDialog fd = new FileDialog(new Frame(), prompt, FileDialog.LOAD);
1374 FileDialog fd = new FileDialog(editor, prompt, FileDialog.LOAD);
1375 fd.setVisible(true);
1376
1377 String directory = fd.getDirectory();
1378 String filename = fd.getFile();
1379 if (filename == null) return;
1380
1381 // copy the file into the folder. if people would rather
1382 // move instead of copy, they can do it by hand
1383 File sourceFile = new File(directory, filename);
1384
1385 // now do the work of adding the file
1386 boolean result = addFile(sourceFile);
1387
1388 if (result) {
1389// editor.statusNotice("One file added to the sketch.");
1390 //Done from within TaskAddFile inner class when copying is completed
1391 }
1392 }
1393
1394
1395 /**

Callers 1

buildSketchMenuMethod · 0.95

Calls 7

ensureExistenceMethod · 0.95
isReadOnlyMethod · 0.95
showMessageMethod · 0.95
textMethod · 0.95
addFileMethod · 0.95
getFileMethod · 0.80
setVisibleMethod · 0.65

Tested by

no test coverage detected