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