Skip to content

Commit 42fa932

Browse files
committed
Merge branch 'new-extension' of git@github.com:arduino/Arduino
2 parents a7352b8 + 80bb16d commit 42fa932

File tree

30 files changed

+1005
-397
lines changed

30 files changed

+1005
-397
lines changed

app/src/processing/app/Base.java

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ protected String createNewUntitled() throws IOException {
545545
newbieDir.mkdirs();
546546

547547
// Make an empty pde file
548-
File newbieFile = new File(newbieDir, newbieName + ".pde");
548+
File newbieFile = new File(newbieDir, newbieName + ".ino");
549549
new FileOutputStream(newbieFile); // create the file
550550
return newbieFile.getAbsolutePath();
551551
}
@@ -637,7 +637,8 @@ public void handleOpenPrompt() {
637637
public boolean accept(File dir, String name) {
638638
// TODO this doesn't seem to ever be used. AWESOME.
639639
//System.out.println("check filter on " + dir + " " + name);
640-
return name.toLowerCase().endsWith(".pde");
640+
return name.toLowerCase().endsWith(".ino")
641+
|| name.toLowerCase().endsWith(".pde");
641642
}
642643
});
643644

@@ -1016,22 +1017,28 @@ public void actionPerformed(ActionEvent actionevent) {
10161017
}
10171018

10181019

1019-
public void rebuildBurnBootloaderMenu(JMenu menu) {
1020-
//System.out.println("rebuilding burn bootloader menu");
1020+
public void rebuildProgrammerMenu(JMenu menu) {
1021+
//System.out.println("rebuilding programmer menu");
10211022
menu.removeAll();
1023+
ButtonGroup group = new ButtonGroup();
10221024
for (Target target : targetsTable.values()) {
10231025
for (String programmer : target.getProgrammers().keySet()) {
10241026
AbstractAction action =
10251027
new AbstractAction(
1026-
"w/ " + target.getProgrammers().get(programmer).get("name")) {
1028+
target.getProgrammers().get(programmer).get("name")) {
10271029
public void actionPerformed(ActionEvent actionevent) {
1028-
activeEditor.handleBurnBootloader((String) getValue("target"),
1029-
(String) getValue("programmer"));
1030+
Preferences.set("programmer", getValue("target") + ":" +
1031+
getValue("programmer"));
10301032
}
10311033
};
10321034
action.putValue("target", target.getName());
10331035
action.putValue("programmer", programmer);
1034-
JMenuItem item = new JMenuItem(action);
1036+
JMenuItem item = new JRadioButtonMenuItem(action);
1037+
if (Preferences.get("programmer").equals(target.getName() + ":" +
1038+
programmer)) {
1039+
item.setSelected(true);
1040+
}
1041+
group.add(item);
10351042
menu.add(item);
10361043
}
10371044
}
@@ -1091,7 +1098,10 @@ public void actionPerformed(ActionEvent e) {
10911098
File subfolder = new File(folder, list[i]);
10921099
if (!subfolder.isDirectory()) continue;
10931100

1094-
File entry = new File(subfolder, list[i] + ".pde");
1101+
File entry = new File(subfolder, list[i] + ".ino");
1102+
if (!entry.exists() && (new File(subfolder, list[i] + ".pde")).exists()) {
1103+
entry = new File(subfolder, list[i] + ".pde");
1104+
}
10951105
// if a .pde file of the same prefix as the folder exists..
10961106
if (entry.exists()) {
10971107
//String sanityCheck = sanitizedName(list[i]);

app/src/processing/app/Editor.java

Lines changed: 90 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -538,21 +538,21 @@ public void actionPerformed(ActionEvent e) {
538538
});
539539
fileMenu.add(saveAsMenuItem);
540540

541-
item = newJMenuItem("Upload to I/O Board", 'U');
541+
item = newJMenuItem("Upload", 'U');
542542
item.addActionListener(new ActionListener() {
543543
public void actionPerformed(ActionEvent e) {
544544
handleExport(false);
545545
}
546546
});
547547
fileMenu.add(item);
548548

549-
// item = newJMenuItemShift("Upload to I/O Board (verbose)", 'U');
550-
// item.addActionListener(new ActionListener() {
551-
// public void actionPerformed(ActionEvent e) {
552-
// handleExport(true);
553-
// }
554-
// });
555-
// fileMenu.add(item);
549+
item = newJMenuItemShift("Upload Using Programmer", 'U');
550+
item.addActionListener(new ActionListener() {
551+
public void actionPerformed(ActionEvent e) {
552+
handleExport(true);
553+
}
554+
});
555+
fileMenu.add(item);
556556

557557
fileMenu.addSeparator();
558558

@@ -618,13 +618,13 @@ public void actionPerformed(ActionEvent e) {
618618
// });
619619
// sketchMenu.add(item);
620620

621-
item = new JMenuItem("Stop");
622-
item.addActionListener(new ActionListener() {
623-
public void actionPerformed(ActionEvent e) {
624-
handleStop();
625-
}
626-
});
627-
sketchMenu.add(item);
621+
// item = new JMenuItem("Stop");
622+
// item.addActionListener(new ActionListener() {
623+
// public void actionPerformed(ActionEvent e) {
624+
// handleStop();
625+
// }
626+
// });
627+
// sketchMenu.add(item);
628628

629629
sketchMenu.addSeparator();
630630

@@ -693,12 +693,20 @@ public void actionPerformed(ActionEvent e) {
693693
serialMenu = new JMenu("Serial Port");
694694
populateSerialMenu();
695695
menu.add(serialMenu);
696-
696+
697697
menu.addSeparator();
698+
699+
JMenu programmerMenu = new JMenu("Programmer");
700+
base.rebuildProgrammerMenu(programmerMenu);
701+
menu.add(programmerMenu);
698702

699-
JMenu bootloaderMenu = new JMenu("Burn Bootloader");
700-
base.rebuildBurnBootloaderMenu(bootloaderMenu);
701-
menu.add(bootloaderMenu);
703+
item = new JMenuItem("Burn Bootloader");
704+
item.addActionListener(new ActionListener() {
705+
public void actionPerformed(ActionEvent e) {
706+
handleBurnBootloader();
707+
}
708+
});
709+
menu.add(item);
702710

703711
menu.addMenuListener(new MenuListener() {
704712
public void menuCanceled(MenuEvent e) {}
@@ -989,8 +997,8 @@ protected void populateSerialMenu() {
989997
//serialMenu.addSeparator();
990998
//serialMenu.add(item);
991999
}
992-
993-
1000+
1001+
9941002
protected JMenu buildHelpMenu() {
9951003
// To deal with a Mac OS X 10.5 bug, add an extra space after the name
9961004
// so that the OS doesn't try to insert its slow help menu.
@@ -1887,12 +1895,12 @@ public Point getSketchLocation() {
18871895
* Implements Sketch → Stop, or pressing Stop on the toolbar.
18881896
*/
18891897
public void handleStop() { // called by menu or buttons
1890-
toolbar.activate(EditorToolbar.STOP);
1898+
// toolbar.activate(EditorToolbar.STOP);
18911899

18921900
internalCloseRunner();
18931901

18941902
toolbar.deactivate(EditorToolbar.RUN);
1895-
toolbar.deactivate(EditorToolbar.STOP);
1903+
// toolbar.deactivate(EditorToolbar.STOP);
18961904

18971905
// focus the PDE again after quitting presentation mode [toxi 030903]
18981906
toFront();
@@ -2032,14 +2040,65 @@ protected void handleOpenUnchecked(String path, int codeIndex,
20322040
* modifications (if any) to the previous sketch need to be saved.
20332041
*/
20342042
protected boolean handleOpenInternal(String path) {
2043+
// rename .pde files to .ino
2044+
File[] oldFiles = (new File(path)).getParentFile().listFiles(new FilenameFilter() {
2045+
public boolean accept(File dir, String name) {
2046+
return (name.toLowerCase().endsWith(".pde"));
2047+
}
2048+
});
2049+
2050+
if (oldFiles != null && oldFiles.length > 0) {
2051+
if (!Preferences.getBoolean("editor.update_extension")) {
2052+
Object[] options = { "OK", "Cancel" };
2053+
String prompt =
2054+
"In Arduino 1.0, the file extension for sketches changed\n" +
2055+
"from \".pde\" to \".ino\". This version of the software only\n" +
2056+
"supports the new extension. Rename the files in this sketch\n" +
2057+
"(and future sketches) and continue?";
2058+
2059+
int result = JOptionPane.showOptionDialog(this,
2060+
prompt,
2061+
"New extension",
2062+
JOptionPane.YES_NO_OPTION,
2063+
JOptionPane.QUESTION_MESSAGE,
2064+
null,
2065+
options,
2066+
options[0]);
2067+
if (result != JOptionPane.YES_OPTION) {
2068+
return false;
2069+
}
2070+
2071+
Preferences.setBoolean("editor.update_extension", true);
2072+
}
2073+
2074+
for (int i = 0; i < oldFiles.length; i++) {
2075+
String oldPath = oldFiles[i].getPath();
2076+
File newFile = new File(oldPath.substring(0, oldPath.length() - 4) + ".ino");
2077+
try {
2078+
Base.copyFile(oldFiles[i], newFile);
2079+
} catch (IOException e) {
2080+
Base.showWarning("Error", "Could not copy to a proper location.", e);
2081+
return false;
2082+
}
2083+
2084+
// remove the original file, so user doesn't get confused
2085+
oldFiles[i].delete();
2086+
2087+
// update with the new path
2088+
if (oldFiles[i].compareTo(new File(path)) == 0) {
2089+
path = newFile.getAbsolutePath();
2090+
}
2091+
}
2092+
}
2093+
20352094
// check to make sure that this .pde file is
20362095
// in a folder of the same name
20372096
File file = new File(path);
20382097
File parentFile = new File(file.getParent());
20392098
String parentName = parentFile.getName();
2040-
String pdeName = parentName + ".pde";
2099+
String pdeName = parentName + ".ino";
20412100
File altFile = new File(file.getParent(), pdeName);
2042-
2101+
20432102
if (pdeName.equals(file.getName())) {
20442103
// no beef with this guy
20452104

@@ -2049,10 +2108,10 @@ protected boolean handleOpenInternal(String path) {
20492108
path = altFile.getAbsolutePath();
20502109
//System.out.println("found alt file in same folder");
20512110

2052-
} else if (!path.endsWith(".pde")) {
2111+
} else if (!path.endsWith(".ino")) {
20532112
Base.showWarning("Bad file selected",
20542113
"Processing can only open its own sketches\n" +
2055-
"and other files ending in .pde", null);
2114+
"and other files ending in .ino", null);
20562115
return false;
20572116

20582117
} else {
@@ -2271,13 +2330,13 @@ public boolean serialPrompt() {
22712330
* Made synchronized to (hopefully) avoid problems of people
22722331
* hitting export twice, quickly, and horking things up.
22732332
*/
2274-
synchronized public void handleExport(final boolean verbose) {
2333+
synchronized public void handleExport(final boolean usingProgrammer) {
22752334
//if (!handleExportCheckModified()) return;
22762335
toolbar.activate(EditorToolbar.EXPORT);
22772336
console.clear();
22782337
statusNotice("Uploading to I/O Board...");
22792338

2280-
new Thread(verbose ? exportAppHandler : exportHandler).start();
2339+
new Thread(usingProgrammer ? exportAppHandler : exportHandler).start();
22812340
}
22822341

22832342
// DAM: in Arduino, this is upload
@@ -2395,14 +2454,14 @@ public void handleSerial() {
23952454
}
23962455

23972456

2398-
protected void handleBurnBootloader(final String target, final String programmer) {
2457+
protected void handleBurnBootloader() {
23992458
console.clear();
24002459
statusNotice("Burning bootloader to I/O Board (this may take a minute)...");
24012460
SwingUtilities.invokeLater(new Runnable() {
24022461
public void run() {
24032462
try {
24042463
Uploader uploader = new AvrdudeUploader();
2405-
if (uploader.burnBootloader(target, programmer)) {
2464+
if (uploader.burnBootloader()) {
24062465
statusNotice("Done burning bootloader.");
24072466
} else {
24082467
statusError("Error while burning bootloader.");

app/src/processing/app/EditorToolbar.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
3737

3838
/** Rollover titles for each button. */
3939
static final String title[] = {
40-
"Verify", "Stop", "New", "Open", "Save", "Upload", "Serial Monitor"
40+
"Verify", "Upload", "New", "Open", "Save", "Serial Monitor"
4141
};
4242

4343
/** Titles for each button when the shift key is pressed. */
4444
static final String titleShift[] = {
45-
"Verify (w/ Verbose Output)", "Stop", "New Editor Window", "Open in Another Window", "Save", "Upload (w/ Verbose Output)", "Serial Monitor"
45+
"Verify", "Upload Using Programmer", "New Editor Window", "Open in Another Window", "Save", "Serial Monitor"
4646
};
4747

4848
static final int BUTTON_COUNT = title.length;
@@ -57,14 +57,13 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
5757

5858

5959
static final int RUN = 0;
60-
static final int STOP = 1;
60+
static final int EXPORT = 1;
6161

6262
static final int NEW = 2;
6363
static final int OPEN = 3;
6464
static final int SAVE = 4;
65-
static final int EXPORT = 5;
6665

67-
static final int SERIAL = 6;
66+
static final int SERIAL = 5;
6867

6968
static final int INACTIVE = 0;
7069
static final int ROLLOVER = 1;
@@ -105,11 +104,10 @@ public EditorToolbar(Editor editor, JMenu menu) {
105104

106105
//which[buttonCount++] = NOTHING;
107106
which[buttonCount++] = RUN;
108-
which[buttonCount++] = STOP;
107+
which[buttonCount++] = EXPORT;
109108
which[buttonCount++] = NEW;
110109
which[buttonCount++] = OPEN;
111110
which[buttonCount++] = SAVE;
112-
which[buttonCount++] = EXPORT;
113111
which[buttonCount++] = SERIAL;
114112

115113
currentRollover = -1;
@@ -312,13 +310,13 @@ public void mousePressed(MouseEvent e) {
312310

313311
switch (sel) {
314312
case RUN:
315-
editor.handleRun(e.isShiftDown());
316-
break;
317-
318-
case STOP:
319-
editor.handleStop();
313+
editor.handleRun(false);
320314
break;
321315

316+
// case STOP:
317+
// editor.handleStop();
318+
// break;
319+
//
322320
case OPEN:
323321
popup = menu.getPopupMenu();
324322
popup.show(EditorToolbar.this, x, y);

app/src/processing/app/Preferences.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ public class Preferences {
113113

114114
JTextField sketchbookLocationField;
115115
JCheckBox exportSeparateBox;
116+
JCheckBox verboseCompilationBox;
117+
JCheckBox verboseUploadBox;
116118
JCheckBox deletePreviousBox;
117119
JCheckBox externalEditorBox;
118120
JCheckBox memoryOverrideBox;
@@ -279,6 +281,21 @@ public void actionPerformed(ActionEvent e) {
279281
top += d.height + GUI_BETWEEN;
280282

281283

284+
// Show verbose output during: [ ] compilation [ ] upload
285+
286+
box = Box.createHorizontalBox();
287+
label = new JLabel("Show verbose output during: ");
288+
box.add(label);
289+
verboseCompilationBox = new JCheckBox("compilation ");
290+
box.add(verboseCompilationBox);
291+
verboseUploadBox = new JCheckBox("upload");
292+
box.add(verboseUploadBox);
293+
pain.add(box);
294+
d = box.getPreferredSize();
295+
box.setBounds(left, top, d.width, d.height);
296+
top += d.height + GUI_BETWEEN;
297+
298+
282299
// [ ] Delete previous applet or application folder on export
283300

284301
deletePreviousBox =
@@ -461,6 +478,8 @@ protected void disposeFrame() {
461478
*/
462479
protected void applyFrame() {
463480
// put each of the settings into the table
481+
setBoolean("build.verbose", verboseCompilationBox.isSelected());
482+
setBoolean("upload.verbose", verboseUploadBox.isSelected());
464483
setBoolean("export.delete_target_folder",
465484
deletePreviousBox.isSelected());
466485

@@ -516,6 +535,8 @@ protected void showFrame(Editor editor) {
516535
this.editor = editor;
517536

518537
// set all settings entry boxes to their actual status
538+
verboseCompilationBox.setSelected(getBoolean("build.verbose"));
539+
verboseUploadBox.setSelected(getBoolean("upload.verbose"));
519540
deletePreviousBox.
520541
setSelected(getBoolean("export.delete_target_folder"));
521542

0 commit comments

Comments
 (0)