1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-30 16:24:09 +03:00

Revert "Merge branch 'new-extension' of git@github.com:arduino/Arduino"

This reverts commit 42fa932ceb, reversing
changes made to a7352b894f.

See: http://www.kernel.org/pub/software/scm/git/docs/howto/revert-a-faulty-merge.txt for information on how to merge the branch in later.
This commit is contained in:
David A. Mellis
2011-02-25 18:23:34 -05:00
parent b4f2bd9761
commit 896b1a48a1
30 changed files with 396 additions and 1004 deletions

View File

@ -545,7 +545,7 @@ public class Base {
newbieDir.mkdirs();
// Make an empty pde file
File newbieFile = new File(newbieDir, newbieName + ".ino");
File newbieFile = new File(newbieDir, newbieName + ".pde");
new FileOutputStream(newbieFile); // create the file
return newbieFile.getAbsolutePath();
}
@ -637,8 +637,7 @@ public class Base {
public boolean accept(File dir, String name) {
// TODO this doesn't seem to ever be used. AWESOME.
//System.out.println("check filter on " + dir + " " + name);
return name.toLowerCase().endsWith(".ino")
|| name.toLowerCase().endsWith(".pde");
return name.toLowerCase().endsWith(".pde");
}
});
@ -1017,28 +1016,22 @@ public class Base {
}
public void rebuildProgrammerMenu(JMenu menu) {
//System.out.println("rebuilding programmer menu");
public void rebuildBurnBootloaderMenu(JMenu menu) {
//System.out.println("rebuilding burn bootloader menu");
menu.removeAll();
ButtonGroup group = new ButtonGroup();
for (Target target : targetsTable.values()) {
for (String programmer : target.getProgrammers().keySet()) {
AbstractAction action =
new AbstractAction(
target.getProgrammers().get(programmer).get("name")) {
"w/ " + target.getProgrammers().get(programmer).get("name")) {
public void actionPerformed(ActionEvent actionevent) {
Preferences.set("programmer", getValue("target") + ":" +
getValue("programmer"));
activeEditor.handleBurnBootloader((String) getValue("target"),
(String) getValue("programmer"));
}
};
action.putValue("target", target.getName());
action.putValue("programmer", programmer);
JMenuItem item = new JRadioButtonMenuItem(action);
if (Preferences.get("programmer").equals(target.getName() + ":" +
programmer)) {
item.setSelected(true);
}
group.add(item);
JMenuItem item = new JMenuItem(action);
menu.add(item);
}
}
@ -1098,10 +1091,7 @@ public class Base {
File subfolder = new File(folder, list[i]);
if (!subfolder.isDirectory()) continue;
File entry = new File(subfolder, list[i] + ".ino");
if (!entry.exists() && (new File(subfolder, list[i] + ".pde")).exists()) {
entry = new File(subfolder, list[i] + ".pde");
}
File entry = new File(subfolder, list[i] + ".pde");
// if a .pde file of the same prefix as the folder exists..
if (entry.exists()) {
//String sanityCheck = sanitizedName(list[i]);

View File

@ -538,7 +538,7 @@ public class Editor extends JFrame implements RunnerListener {
});
fileMenu.add(saveAsMenuItem);
item = newJMenuItem("Upload", 'U');
item = newJMenuItem("Upload to I/O Board", 'U');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleExport(false);
@ -546,13 +546,13 @@ public class Editor extends JFrame implements RunnerListener {
});
fileMenu.add(item);
item = newJMenuItemShift("Upload Using Programmer", 'U');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleExport(true);
}
});
fileMenu.add(item);
// item = newJMenuItemShift("Upload to I/O Board (verbose)", 'U');
// item.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent e) {
// handleExport(true);
// }
// });
// fileMenu.add(item);
fileMenu.addSeparator();
@ -618,13 +618,13 @@ public class Editor extends JFrame implements RunnerListener {
// });
// sketchMenu.add(item);
// item = new JMenuItem("Stop");
// item.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent e) {
// handleStop();
// }
// });
// sketchMenu.add(item);
item = new JMenuItem("Stop");
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleStop();
}
});
sketchMenu.add(item);
sketchMenu.addSeparator();
@ -693,20 +693,12 @@ public class Editor extends JFrame implements RunnerListener {
serialMenu = new JMenu("Serial Port");
populateSerialMenu();
menu.add(serialMenu);
menu.addSeparator();
JMenu programmerMenu = new JMenu("Programmer");
base.rebuildProgrammerMenu(programmerMenu);
menu.add(programmerMenu);
item = new JMenuItem("Burn Bootloader");
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleBurnBootloader();
}
});
menu.add(item);
JMenu bootloaderMenu = new JMenu("Burn Bootloader");
base.rebuildBurnBootloaderMenu(bootloaderMenu);
menu.add(bootloaderMenu);
menu.addMenuListener(new MenuListener() {
public void menuCanceled(MenuEvent e) {}
@ -997,8 +989,8 @@ public class Editor extends JFrame implements RunnerListener {
//serialMenu.addSeparator();
//serialMenu.add(item);
}
protected JMenu buildHelpMenu() {
// To deal with a Mac OS X 10.5 bug, add an extra space after the name
// so that the OS doesn't try to insert its slow help menu.
@ -1895,12 +1887,12 @@ public class Editor extends JFrame implements RunnerListener {
* Implements Sketch → Stop, or pressing Stop on the toolbar.
*/
public void handleStop() { // called by menu or buttons
// toolbar.activate(EditorToolbar.STOP);
toolbar.activate(EditorToolbar.STOP);
internalCloseRunner();
toolbar.deactivate(EditorToolbar.RUN);
// toolbar.deactivate(EditorToolbar.STOP);
toolbar.deactivate(EditorToolbar.STOP);
// focus the PDE again after quitting presentation mode [toxi 030903]
toFront();
@ -2040,65 +2032,14 @@ public class Editor extends JFrame implements RunnerListener {
* modifications (if any) to the previous sketch need to be saved.
*/
protected boolean handleOpenInternal(String path) {
// rename .pde files to .ino
File[] oldFiles = (new File(path)).getParentFile().listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return (name.toLowerCase().endsWith(".pde"));
}
});
if (oldFiles != null && oldFiles.length > 0) {
if (!Preferences.getBoolean("editor.update_extension")) {
Object[] options = { "OK", "Cancel" };
String prompt =
"In Arduino 1.0, the file extension for sketches changed\n" +
"from \".pde\" to \".ino\". This version of the software only\n" +
"supports the new extension. Rename the files in this sketch\n" +
"(and future sketches) and continue?";
int result = JOptionPane.showOptionDialog(this,
prompt,
"New extension",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
options,
options[0]);
if (result != JOptionPane.YES_OPTION) {
return false;
}
Preferences.setBoolean("editor.update_extension", true);
}
for (int i = 0; i < oldFiles.length; i++) {
String oldPath = oldFiles[i].getPath();
File newFile = new File(oldPath.substring(0, oldPath.length() - 4) + ".ino");
try {
Base.copyFile(oldFiles[i], newFile);
} catch (IOException e) {
Base.showWarning("Error", "Could not copy to a proper location.", e);
return false;
}
// remove the original file, so user doesn't get confused
oldFiles[i].delete();
// update with the new path
if (oldFiles[i].compareTo(new File(path)) == 0) {
path = newFile.getAbsolutePath();
}
}
}
// check to make sure that this .pde file is
// in a folder of the same name
File file = new File(path);
File parentFile = new File(file.getParent());
String parentName = parentFile.getName();
String pdeName = parentName + ".ino";
String pdeName = parentName + ".pde";
File altFile = new File(file.getParent(), pdeName);
if (pdeName.equals(file.getName())) {
// no beef with this guy
@ -2108,10 +2049,10 @@ public class Editor extends JFrame implements RunnerListener {
path = altFile.getAbsolutePath();
//System.out.println("found alt file in same folder");
} else if (!path.endsWith(".ino")) {
} else if (!path.endsWith(".pde")) {
Base.showWarning("Bad file selected",
"Processing can only open its own sketches\n" +
"and other files ending in .ino", null);
"and other files ending in .pde", null);
return false;
} else {
@ -2330,13 +2271,13 @@ public class Editor extends JFrame implements RunnerListener {
* Made synchronized to (hopefully) avoid problems of people
* hitting export twice, quickly, and horking things up.
*/
synchronized public void handleExport(final boolean usingProgrammer) {
synchronized public void handleExport(final boolean verbose) {
//if (!handleExportCheckModified()) return;
toolbar.activate(EditorToolbar.EXPORT);
console.clear();
statusNotice("Uploading to I/O Board...");
new Thread(usingProgrammer ? exportAppHandler : exportHandler).start();
new Thread(verbose ? exportAppHandler : exportHandler).start();
}
// DAM: in Arduino, this is upload
@ -2454,14 +2395,14 @@ public class Editor extends JFrame implements RunnerListener {
}
protected void handleBurnBootloader() {
protected void handleBurnBootloader(final String target, final String programmer) {
console.clear();
statusNotice("Burning bootloader to I/O Board (this may take a minute)...");
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
Uploader uploader = new AvrdudeUploader();
if (uploader.burnBootloader()) {
if (uploader.burnBootloader(target, programmer)) {
statusNotice("Done burning bootloader.");
} else {
statusError("Error while burning bootloader.");

View File

@ -37,12 +37,12 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
/** Rollover titles for each button. */
static final String title[] = {
"Verify", "Upload", "New", "Open", "Save", "Serial Monitor"
"Verify", "Stop", "New", "Open", "Save", "Upload", "Serial Monitor"
};
/** Titles for each button when the shift key is pressed. */
static final String titleShift[] = {
"Verify", "Upload Using Programmer", "New Editor Window", "Open in Another Window", "Save", "Serial Monitor"
"Verify (w/ Verbose Output)", "Stop", "New Editor Window", "Open in Another Window", "Save", "Upload (w/ Verbose Output)", "Serial Monitor"
};
static final int BUTTON_COUNT = title.length;
@ -57,13 +57,14 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
static final int RUN = 0;
static final int EXPORT = 1;
static final int STOP = 1;
static final int NEW = 2;
static final int OPEN = 3;
static final int SAVE = 4;
static final int EXPORT = 5;
static final int SERIAL = 5;
static final int SERIAL = 6;
static final int INACTIVE = 0;
static final int ROLLOVER = 1;
@ -104,10 +105,11 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
//which[buttonCount++] = NOTHING;
which[buttonCount++] = RUN;
which[buttonCount++] = EXPORT;
which[buttonCount++] = STOP;
which[buttonCount++] = NEW;
which[buttonCount++] = OPEN;
which[buttonCount++] = SAVE;
which[buttonCount++] = EXPORT;
which[buttonCount++] = SERIAL;
currentRollover = -1;
@ -310,13 +312,13 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
switch (sel) {
case RUN:
editor.handleRun(false);
editor.handleRun(e.isShiftDown());
break;
case STOP:
editor.handleStop();
break;
// case STOP:
// editor.handleStop();
// break;
//
case OPEN:
popup = menu.getPopupMenu();
popup.show(EditorToolbar.this, x, y);

View File

@ -113,8 +113,6 @@ public class Preferences {
JTextField sketchbookLocationField;
JCheckBox exportSeparateBox;
JCheckBox verboseCompilationBox;
JCheckBox verboseUploadBox;
JCheckBox deletePreviousBox;
JCheckBox externalEditorBox;
JCheckBox memoryOverrideBox;
@ -281,21 +279,6 @@ public class Preferences {
top += d.height + GUI_BETWEEN;
// Show verbose output during: [ ] compilation [ ] upload
box = Box.createHorizontalBox();
label = new JLabel("Show verbose output during: ");
box.add(label);
verboseCompilationBox = new JCheckBox("compilation ");
box.add(verboseCompilationBox);
verboseUploadBox = new JCheckBox("upload");
box.add(verboseUploadBox);
pain.add(box);
d = box.getPreferredSize();
box.setBounds(left, top, d.width, d.height);
top += d.height + GUI_BETWEEN;
// [ ] Delete previous applet or application folder on export
deletePreviousBox =
@ -478,8 +461,6 @@ public class Preferences {
*/
protected void applyFrame() {
// put each of the settings into the table
setBoolean("build.verbose", verboseCompilationBox.isSelected());
setBoolean("upload.verbose", verboseUploadBox.isSelected());
setBoolean("export.delete_target_folder",
deletePreviousBox.isSelected());
@ -535,8 +516,6 @@ public class Preferences {
this.editor = editor;
// set all settings entry boxes to their actual status
verboseCompilationBox.setSelected(getBoolean("build.verbose"));
verboseUploadBox.setSelected(getBoolean("upload.verbose"));
deletePreviousBox.
setSelected(getBoolean("export.delete_target_folder"));

View File

@ -315,7 +315,7 @@ public class Sketch {
renamingCode = true;
String prompt = (currentIndex == 0) ?
"New name for sketch:" : "New name for file:";
String oldName = (current.isExtension("ino")) ?
String oldName = (current.isExtension("pde")) ?
current.getPrettyName() : current.getFileName();
editor.status.edit(prompt, oldName);
}
@ -495,7 +495,7 @@ public class Sketch {
}
// if successful, set base properties for the sketch
File newMainFile = new File(newFolder, newName + ".ino");
File newMainFile = new File(newFolder, newName + ".pde");
String newMainFilePath = newMainFile.getAbsolutePath();
// having saved everything and renamed the folder and the main .pde,
@ -860,7 +860,7 @@ public class Sketch {
}
// save the main tab with its new name
File newFile = new File(newFolder, newName + ".ino");
File newFile = new File(newFolder, newName + ".pde");
code[0].saveAs(newFile);
editor.handleOpenUnchecked(newFile.getPath(),
@ -1261,7 +1261,7 @@ public class Sketch {
StringBuffer bigCode = new StringBuffer();
int bigCount = 0;
for (SketchCode sc : code) {
if (sc.isExtension("ino")) {
if (sc.isExtension("pde")) {
sc.setPreprocOffset(bigCount);
bigCode.append(sc.getProgram());
bigCode.append('\n');
@ -1357,7 +1357,7 @@ public class Sketch {
}
// sc.setPreprocName(filename);
} else if (sc.isExtension("ino")) {
} else if (sc.isExtension("pde")) {
// The compiler and runner will need this to have a proper offset
sc.addPreprocOffset(headerOffset);
}
@ -1386,7 +1386,7 @@ public class Sketch {
// SketchCode errorCode = null;
// if (filename.equals(appletJavaFile)) {
// for (SketchCode code : getCode()) {
// if (code.isExtension("ino")) {
// if (code.isExtension("pde")) {
// if (line >= code.getPreprocOffset()) {
// errorCode = code;
// }
@ -1520,15 +1520,15 @@ public class Sketch {
}
protected boolean exportApplet(boolean usingProgrammer) throws Exception {
return exportApplet(tempBuildFolder.getAbsolutePath(), usingProgrammer);
protected boolean exportApplet(boolean verbose) throws Exception {
return exportApplet(tempBuildFolder.getAbsolutePath(), verbose);
}
/**
* Handle export to applet.
*/
public boolean exportApplet(String appletPath, boolean usingProgrammer)
public boolean exportApplet(String appletPath, boolean verbose)
throws RunnerException, IOException, SerialException {
// Make sure the user didn't hide the sketch folder
@ -1565,7 +1565,7 @@ public class Sketch {
// return false;
// }
upload(appletFolder.getPath(), foundName, usingProgrammer);
upload(appletFolder.getPath(), foundName, verbose);
return true;
}
@ -1592,7 +1592,7 @@ public class Sketch {
}
protected String upload(String buildPath, String suggestedClassName, boolean usingProgrammer)
protected String upload(String buildPath, String suggestedClassName, boolean verbose)
throws RunnerException, SerialException {
Uploader uploader;
@ -1602,7 +1602,7 @@ public class Sketch {
uploader = new AvrdudeUploader();
boolean success = uploader.uploadUsingPreferences(buildPath,
suggestedClassName,
usingProgrammer);
verbose);
return success ? suggestedClassName : null;
}
@ -1791,7 +1791,7 @@ public class Sketch {
* Returns the default extension for this editor setup.
*/
public String getDefaultExtension() {
return "ino";
return "pde";
}
@ -1799,7 +1799,7 @@ public class Sketch {
* Returns a String[] array of proper extensions.
*/
public String[] getExtensions() {
return new String[] { "ino", "c", "cpp", "h" };
return new String[] { "pde", "c", "cpp", "h" };
}

View File

@ -42,28 +42,33 @@ public class AvrdudeUploader extends Uploader {
public AvrdudeUploader() {
}
public boolean uploadUsingPreferences(String buildPath, String className, boolean usingProgrammer)
// XXX: add support for uploading sketches using a programmer
public boolean uploadUsingPreferences(String buildPath, String className, boolean verbose)
throws RunnerException, SerialException {
this.verbose = verbose;
Map<String, String> boardPreferences = Base.getBoardPreferences();
String uploadUsing = boardPreferences.get("upload.using");
if (uploadUsing == null) {
// fall back on global preference
uploadUsing = Preferences.get("upload.using");
}
if (uploadUsing.equals("bootloader")) {
return uploadViaBootloader(buildPath, className);
} else {
Target t;
// if no protocol is specified for this board, assume it lacks a
// bootloader and upload using the selected programmer.
if (usingProgrammer || boardPreferences.get("upload.protocol") == null) {
String programmer = Preferences.get("programmer");
Target target = Base.getTarget();
if (programmer.indexOf(":") != -1) {
target = Base.targetsTable.get(programmer.substring(0, programmer.indexOf(":")));
programmer = programmer.substring(programmer.indexOf(":") + 1);
if (uploadUsing.indexOf(':') == -1) {
t = Base.getTarget(); // the current target (associated with the board)
} else {
String targetName = uploadUsing.substring(0, uploadUsing.indexOf(':'));
t = Base.targetsTable.get(targetName);
uploadUsing = uploadUsing.substring(uploadUsing.indexOf(':') + 1);
}
Collection params = getProgrammerCommands(target, programmer);
Collection params = getProgrammerCommands(t, uploadUsing);
params.add("-Uflash:w:" + buildPath + File.separator + className + ".hex:i");
return avrdude(params);
}
return uploadViaBootloader(buildPath, className);
}
private boolean uploadViaBootloader(String buildPath, String className)
@ -91,14 +96,8 @@ public class AvrdudeUploader extends Uploader {
return avrdude(commandDownloader);
}
public boolean burnBootloader() throws RunnerException {
String programmer = Preferences.get("programmer");
Target target = Base.getTarget();
if (programmer.indexOf(":") != -1) {
target = Base.targetsTable.get(programmer.substring(0, programmer.indexOf(":")));
programmer = programmer.substring(programmer.indexOf(":") + 1);
}
return burnBootloader(getProgrammerCommands(target, programmer));
public boolean burnBootloader(String targetName, String programmer) throws RunnerException {
return burnBootloader(getProgrammerCommands(Base.targetsTable.get(targetName), programmer));
}
private Collection getProgrammerCommands(Target target, String programmer) {

View File

@ -64,10 +64,10 @@ public abstract class Uploader implements MessageConsumer {
public Uploader() {
}
public abstract boolean uploadUsingPreferences(String buildPath, String className, boolean usingProgrammer)
public abstract boolean uploadUsingPreferences(String buildPath, String className, boolean verbose)
throws RunnerException, SerialException;
public abstract boolean burnBootloader() throws RunnerException;
public abstract boolean burnBootloader(String target, String programmer) throws RunnerException;
protected void flushSerialBuffer() throws RunnerException, SerialException {
// Cleanup the serial buffer

View File

@ -44,8 +44,8 @@ public class Platform extends processing.app.Platform {
static final String openCommand =
System.getProperty("user.dir").replace('/', '\\') +
"\\arduino.exe \"%1\"";
static final String DOC = "Arduino.Document";
"\\processing.exe \"%1\"";
static final String DOC = "Processing.Document";
public void init(Base base) {
super.init(base);
@ -86,13 +86,13 @@ public class Platform extends processing.app.Platform {
*/
protected void setAssociations() throws UnsupportedEncodingException {
if (Registry.createKey(REGISTRY_ROOT_KEY.CLASSES_ROOT,
"", ".ino") &&
"", ".pde") &&
Registry.setStringValue(REGISTRY_ROOT_KEY.CLASSES_ROOT,
".ino", "", DOC) &&
".pde", "", DOC) &&
Registry.createKey(REGISTRY_ROOT_KEY.CLASSES_ROOT, "", DOC) &&
Registry.setStringValue(REGISTRY_ROOT_KEY.CLASSES_ROOT, DOC, "",
"Arduino Source Code") &&
"Processing Source Code") &&
Registry.createKey(REGISTRY_ROOT_KEY.CLASSES_ROOT,
DOC, "shell") &&