Prompt the user for a new file to the sketch, then call the other addFile() function to actually add it.
()
| 1230 | * other addFile() function to actually add it. |
| 1231 | */ |
| 1232 | public void handleAddFile() { |
| 1233 | // make sure the user didn't hide the sketch folder |
| 1234 | ensureExistence(); |
| 1235 | |
| 1236 | // if read-only, give an error |
| 1237 | if (isReadOnly()) { |
| 1238 | // if the files are read-only, need to first do a "save as". |
| 1239 | Messages.showMessage(Language.text("add_file.messages.is_read_only"), |
| 1240 | Language.text("add_file.messages.is_read_only.description")); |
| 1241 | return; |
| 1242 | } |
| 1243 | |
| 1244 | // get a dialog, select a file to add to the sketch |
| 1245 | String prompt = Language.text("file"); |
| 1246 | //FileDialog fd = new FileDialog(new Frame(), prompt, FileDialog.LOAD); |
| 1247 | FileDialog fd = new FileDialog(editor, prompt, FileDialog.LOAD); |
| 1248 | fd.setVisible(true); |
| 1249 | |
| 1250 | String directory = fd.getDirectory(); |
| 1251 | String filename = fd.getFile(); |
| 1252 | if (filename == null) return; |
| 1253 | |
| 1254 | // copy the file into the folder. if people would rather |
| 1255 | // it move instead of copy, they can do it by hand |
| 1256 | File sourceFile = new File(directory, filename); |
| 1257 | |
| 1258 | // now do the work of adding the file |
| 1259 | boolean result = addFile(sourceFile); |
| 1260 | |
| 1261 | if (result) { |
| 1262 | // editor.statusNotice("One file added to the sketch."); |
| 1263 | //Done from within TaskAddFile inner class when copying is completed |
| 1264 | } |
| 1265 | } |
| 1266 | |
| 1267 | |
| 1268 | /** |
no test coverage detected