mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-17 06:52:18 +01:00
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
This commit is contained in:
parent
a398aaffe5
commit
43fa225724
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user