@@ -561,48 +561,46 @@ public boolean save() throws IOException {
561561 //if (!modified) return false;
562562
563563 if (isReadOnly (BaseNoGui .librariesIndexer .getInstalledLibraries (), BaseNoGui .getExamplesPath ())) {
564- // if the files are read-only, need to first do a "save as".
565564 Base .showMessage (tr ("Sketch is read-only" ),
566- tr ("Some files are marked \" read-only\" , so you'll\n " +
567- "need to re-save this sketch to another location." ));
568- // if the user cancels, give up on the save()
569- if (!saveAs ()) return false ;
570- } else {
571- // rename .pde files to .ino
572- File mainFile = new File (getMainFilePath ());
573- File mainFolder = mainFile .getParentFile ();
574- File [] pdeFiles = mainFolder .listFiles ((dir , name ) -> {
575- return name .toLowerCase ().endsWith (".pde" );
576- });
577-
578- if (pdeFiles != null && pdeFiles .length > 0 ) {
579- if (PreferencesData .get ("editor.update_extension" ) == null ) {
580- Object [] options = { tr ("OK" ), tr ("Cancel" ) };
581- int result = JOptionPane .showOptionDialog (editor ,
582- tr ("In Arduino 1.0, the default file extension has changed\n " +
583- "from .pde to .ino. New sketches (including those created\n " +
584- "by \" Save-As\" ) will use the new extension. The extension\n " +
585- "of existing sketches will be updated on save, but you can\n " +
586- "disable this in the Preferences dialog.\n " +
587- "\n " +
588- "Save sketch and update its extension?" ),
589- tr (".pde -> .ino" ),
590- JOptionPane .OK_CANCEL_OPTION ,
591- JOptionPane .QUESTION_MESSAGE ,
592- null ,
593- options ,
594- options [0 ]);
595-
596- if (result != JOptionPane .OK_OPTION ) return false ; // save cancelled
597-
598- PreferencesData .setBoolean ("editor.update_extension" , true );
599- }
565+ tr ("Some files are marked \" read-only\" , so you'll\n " +
566+ "need to re-save this sketch to another location." ));
567+ return saveAs ();
568+ }
600569
601- if (PreferencesData .getBoolean ("editor.update_extension" )) {
602- // Do rename of all .pde files to new .ino extension
603- for (File pdeFile : pdeFiles )
604- renameCodeToInoExtension (pdeFile );
605- }
570+ // rename .pde files to .ino
571+ File mainFile = new File (getMainFilePath ());
572+ File mainFolder = mainFile .getParentFile ();
573+ File [] pdeFiles = mainFolder .listFiles ((dir , name ) -> {
574+ return name .toLowerCase ().endsWith (".pde" );
575+ });
576+
577+ if (pdeFiles != null && pdeFiles .length > 0 ) {
578+ if (PreferencesData .get ("editor.update_extension" ) == null ) {
579+ Object [] options = {tr ("OK" ), tr ("Cancel" )};
580+ int result = JOptionPane .showOptionDialog (editor ,
581+ tr ("In Arduino 1.0, the default file extension has changed\n " +
582+ "from .pde to .ino. New sketches (including those created\n " +
583+ "by \" Save-As\" ) will use the new extension. The extension\n " +
584+ "of existing sketches will be updated on save, but you can\n " +
585+ "disable this in the Preferences dialog.\n " +
586+ "\n " +
587+ "Save sketch and update its extension?" ),
588+ tr (".pde -> .ino" ),
589+ JOptionPane .OK_CANCEL_OPTION ,
590+ JOptionPane .QUESTION_MESSAGE ,
591+ null ,
592+ options ,
593+ options [0 ]);
594+
595+ if (result != JOptionPane .OK_OPTION ) return false ; // save cancelled
596+
597+ PreferencesData .setBoolean ("editor.update_extension" , true );
598+ }
599+
600+ if (PreferencesData .getBoolean ("editor.update_extension" )) {
601+ // Do rename of all .pde files to new .ino extension
602+ for (File pdeFile : pdeFiles )
603+ renameCodeToInoExtension (pdeFile );
606604 }
607605 }
608606
0 commit comments