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 58cbd3deb..4a90795de 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -707,21 +707,45 @@ 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) { + 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); + } } - }); - - 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++) { 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