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

Method handleRenameCode

app/src/processing/app/Sketch.java:327–360  ·  view source on GitHub ↗

Handler for the "Rename Code" menu option.

()

Source from the content-addressed store, hash-verified

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 /**

Callers 1

actionPerformedMethod · 0.80

Calls 12

ensureExistenceMethod · 0.95
isUntitledMethod · 0.95
showMessageMethod · 0.95
textMethod · 0.95
isModifiedMethod · 0.95
isReadOnlyMethod · 0.95
getBooleanMethod · 0.95
promptForTabNameMethod · 0.95
isExtensionMethod · 0.80
getDefaultExtensionMethod · 0.45
getPrettyNameMethod · 0.45
getFileNameMethod · 0.45

Tested by

no test coverage detected