Handler for the "Rename Code" menu option.
()
| 325 | * Handler for the "Rename Code" menu option. |
| 326 | */ |
| 327 | public void handleRenameCode() { |
| 328 | // make sure the user didn't hide the sketch folder |
| 329 | ensureExistence(); |
| 330 | |
| 331 | if (currentIndex == 0 && isUntitled()) { |
| 332 | Messages.showMessage(Language.text("rename.messages.is_untitled"), |
| 333 | Language.text("rename.messages.is_untitled.description")); |
| 334 | return; |
| 335 | } |
| 336 | |
| 337 | if (isModified()) { |
| 338 | Messages.showMessage(Language.text("menu.file.save"), |
| 339 | Language.text("rename.messages.is_modified")); |
| 340 | return; |
| 341 | } |
| 342 | |
| 343 | // if read-only, give an error |
| 344 | if (isReadOnly()) { |
| 345 | // if the files are read-only, need to first do a "save as". |
| 346 | Messages.showMessage(Language.text("rename.messages.is_read_only"), |
| 347 | Language.text("rename.messages.is_read_only.description")); |
| 348 | return; |
| 349 | } |
| 350 | |
| 351 | // ask for new name of file (internal to window) |
| 352 | // TODO maybe just pop up a text area? |
| 353 | renamingCode = true; |
| 354 | String prompt = (currentIndex == 0 && Preferences.getBoolean("editor.sync_folder_and_filename")) ? |
| 355 | Language.text("editor.sketch.rename.description") : |
| 356 | Language.text("editor.tab.rename.description"); |
| 357 | String oldName = (current.isExtension(mode.getDefaultExtension())) ? |
| 358 | current.getPrettyName() : current.getFileName(); |
| 359 | promptForTabName(prompt + ":", oldName); |
| 360 | } |
| 361 | |
| 362 | |
| 363 | /** |
no test coverage detected