From 026794f1eb3f6df861158128334ca1fcbc6de82f Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Fri, 16 Sep 2011 12:45:24 -0400 Subject: [PATCH 1/3] Don't rename read-only files in sketch on save (which becomes save-as). http://code.google.com/p/arduino/issues/detail?id=639 --- app/src/processing/app/Sketch.java | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 58cbd3deb..edde19c11 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -707,21 +707,21 @@ public class Sketch { "need to re-save this sketch to another location."); // if the user cancels, give up on the save() if (!saveAs()) return false; - } - - // rename .pde files to .ino - File mainFile = new File(getMainFilePath()); - File mainFolder = mainFile.getParentFile(); - File[] pdeFiles = mainFolder.listFiles(new FilenameFilter() { - public boolean accept(File dir, String name) { - return name.toLowerCase().endsWith(".pde"); + } else { + // rename .pde files to .ino + File mainFile = new File(getMainFilePath()); + File mainFolder = mainFile.getParentFile(); + File[] pdeFiles = mainFolder.listFiles(new FilenameFilter() { + public boolean accept(File dir, String name) { + return name.toLowerCase().endsWith(".pde"); + } + }); + + if (pdeFiles != null && pdeFiles.length > 0) { + // Do rename of all .pde files to new .ino extension + for (File pdeFile : pdeFiles) + renameCodeToInoExtension(pdeFile); } - }); - - if (pdeFiles != null && pdeFiles.length > 0) { - // Do rename of all .pde files to new .ino extension - for (File pdeFile : pdeFiles) - renameCodeToInoExtension(pdeFile); } for (int i = 0; i < codeCount; i++) { From 43fa22572482070ee4ed089360ff42328c820069 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Fri, 16 Sep 2011 13:30:50 -0400 Subject: [PATCH 2/3] Dialog and preference about renaming .pde to .ino files on save. The new extension (.ino) is used by default for all new sketches (whether created with new or save as). It's possible, however, to control the behavior on save. The first time you save a sketch with a .pde file, you're prompted to rename it or cancel the save. There's a preference that allow selecting whether or not .pde files are renamed on save. http://code.google.com/p/arduino/issues/detail?id=644 --- app/src/processing/app/Preferences.java | 16 ++++++++++++- app/src/processing/app/Sketch.java | 30 ++++++++++++++++++++++--- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/Preferences.java index 315620033..4cee5ad8e 100644 --- a/app/src/processing/app/Preferences.java +++ b/app/src/processing/app/Preferences.java @@ -121,6 +121,7 @@ public class Preferences { JTextField memoryField; JCheckBox checkUpdatesBox; JTextField fontSizeField; + JCheckBox updateExtensionBox; JCheckBox autoAssociateBox; @@ -325,7 +326,15 @@ public class Preferences { checkUpdatesBox.setBounds(left, top, d.width + 10, d.height); right = Math.max(right, left + d.width); top += d.height + GUI_BETWEEN; - + + // [ ] Update sketch files to new extension on save (.pde -> .ino) + + updateExtensionBox = new JCheckBox("Update sketch files to new extension on save (.pde -> .ino)"); + pain.add(updateExtensionBox); + d = updateExtensionBox.getPreferredSize(); + updateExtensionBox.setBounds(left, top, d.width + 10, d.height); + right = Math.max(right, left + d.width); + top += d.height + GUI_BETWEEN; // [ ] Automatically associate .pde files with Processing @@ -526,6 +535,8 @@ public class Preferences { setBoolean("platform.auto_file_type_associations", autoAssociateBox.isSelected()); } + + setBoolean("editor.update_extension", updateExtensionBox.isSelected()); editor.applyPreferences(); } @@ -558,6 +569,9 @@ public class Preferences { autoAssociateBox. setSelected(getBoolean("platform.auto_file_type_associations")); } + + updateExtensionBox.setSelected(get("editor.update_extension") == null || + getBoolean("editor.update_extension")); dialog.setVisible(true); } diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index edde19c11..4a90795de 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -718,9 +718,33 @@ public class Sketch { }); if (pdeFiles != null && pdeFiles.length > 0) { - // Do rename of all .pde files to new .ino extension - for (File pdeFile : pdeFiles) - renameCodeToInoExtension(pdeFile); + if (Preferences.get("editor.update_extension") == null) { + Object[] options = { "OK", "Cancel" }; + int result = JOptionPane.showOptionDialog(editor, + "In Arduino 1.0, the default file extension has changed\n" + + "from .pde to .ino. New sketches (including those created\n" + + "by \"Save-As\" will use the new extension. The extension\n" + + "of existing sketches will be updated on save, but you can\n" + + "disable this in the Preferences dialog.\n" + + "\n" + + "Save sketch and update its extension?", + ".pde -> .ino", + JOptionPane.OK_CANCEL_OPTION, + JOptionPane.QUESTION_MESSAGE, + null, + options, + options[0]); + + if (result != JOptionPane.OK_OPTION) return false; // save cancelled + + Preferences.setBoolean("editor.update_extension", true); + } + + if (Preferences.getBoolean("editor.update_extension")) { + // Do rename of all .pde files to new .ino extension + for (File pdeFile : pdeFiles) + renameCodeToInoExtension(pdeFile); + } } } From 5ec35fc68c8e4203adbdbc06c86d6093c1522974 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Fri, 16 Sep 2011 14:24:11 -0400 Subject: [PATCH 3/3] Moving Leonardo after Uno. --- hardware/arduino/boards.txt | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/hardware/arduino/boards.txt b/hardware/arduino/boards.txt index 87ca07de7..a6599f8cf 100644 --- a/hardware/arduino/boards.txt +++ b/hardware/arduino/boards.txt @@ -1,23 +1,5 @@ ############################################################## -leonardo.name=Arduino Leonardo -leonardo.upload.protocol=arduino -leonardo.upload.maximum_size=30720 -leonardo.upload.speed=1200 -leonardo.bootloader.low_fuses=0xde -leonardo.bootloader.high_fuses=0xda -leonardo.bootloader.extended_fuses=0xcb -leonardo.bootloader.path=diskloader -leonardo.bootloader.file=DiskLoader.hex -leonardo.bootloader.unlock_bits=0x3F -leonardo.bootloader.lock_bits=0x2F -leonardo.build.mcu=atmega32u4 -leonardo.build.f_cpu=16000000L -leonardo.build.core=arduino -leonardo.build.variant=leonardo - -############################################################## - uno.name=Arduino Uno uno.upload.protocol=arduino uno.upload.maximum_size=32256 @@ -36,6 +18,24 @@ uno.build.variant=standard ############################################################## +leonardo.name=Arduino Leonardo +leonardo.upload.protocol=arduino +leonardo.upload.maximum_size=30720 +leonardo.upload.speed=1200 +leonardo.bootloader.low_fuses=0xde +leonardo.bootloader.high_fuses=0xda +leonardo.bootloader.extended_fuses=0xcb +leonardo.bootloader.path=diskloader +leonardo.bootloader.file=DiskLoader.hex +leonardo.bootloader.unlock_bits=0x3F +leonardo.bootloader.lock_bits=0x2F +leonardo.build.mcu=atmega32u4 +leonardo.build.f_cpu=16000000L +leonardo.build.core=arduino +leonardo.build.variant=leonardo + +############################################################## + atmega328.name=Arduino Duemilanove w/ ATmega328 atmega328.upload.protocol=arduino