This commit is contained in:
Zach Eveland 2011-09-16 14:34:55 -04:00
commit cd5ecfff1c
3 changed files with 71 additions and 33 deletions

View File

@ -121,6 +121,7 @@ public class Preferences {
JTextField memoryField; JTextField memoryField;
JCheckBox checkUpdatesBox; JCheckBox checkUpdatesBox;
JTextField fontSizeField; JTextField fontSizeField;
JCheckBox updateExtensionBox;
JCheckBox autoAssociateBox; JCheckBox autoAssociateBox;
@ -326,6 +327,14 @@ public class Preferences {
right = Math.max(right, left + d.width); right = Math.max(right, left + d.width);
top += d.height + GUI_BETWEEN; 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 // [ ] Automatically associate .pde files with Processing
@ -527,6 +536,8 @@ public class Preferences {
autoAssociateBox.isSelected()); autoAssociateBox.isSelected());
} }
setBoolean("editor.update_extension", updateExtensionBox.isSelected());
editor.applyPreferences(); editor.applyPreferences();
} }
@ -559,6 +570,9 @@ public class Preferences {
setSelected(getBoolean("platform.auto_file_type_associations")); setSelected(getBoolean("platform.auto_file_type_associations"));
} }
updateExtensionBox.setSelected(get("editor.update_extension") == null ||
getBoolean("editor.update_extension"));
dialog.setVisible(true); dialog.setVisible(true);
} }

View File

@ -707,8 +707,7 @@ public class Sketch {
"need to re-save this sketch to another location."); "need to re-save this sketch to another location.");
// if the user cancels, give up on the save() // if the user cancels, give up on the save()
if (!saveAs()) return false; if (!saveAs()) return false;
} } else {
// rename .pde files to .ino // rename .pde files to .ino
File mainFile = new File(getMainFilePath()); File mainFile = new File(getMainFilePath());
File mainFolder = mainFile.getParentFile(); File mainFolder = mainFile.getParentFile();
@ -719,10 +718,35 @@ public class Sketch {
}); });
if (pdeFiles != null && pdeFiles.length > 0) { 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 // Do rename of all .pde files to new .ino extension
for (File pdeFile : pdeFiles) for (File pdeFile : pdeFiles)
renameCodeToInoExtension(pdeFile); renameCodeToInoExtension(pdeFile);
} }
}
}
for (int i = 0; i < codeCount; i++) { for (int i = 0; i < codeCount; i++) {
if (code[i].isModified()) if (code[i].isModified())

View File

@ -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.name=Arduino Uno
uno.upload.protocol=arduino uno.upload.protocol=arduino
uno.upload.maximum_size=32256 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.name=Arduino Duemilanove w/ ATmega328
atmega328.upload.protocol=arduino atmega328.upload.protocol=arduino