Skip to content

Commit 6a86cbc

Browse files
committed
Merge branch 'ide-1.5.x' into SoftwareSerial
2 parents b95533f + 84acf46 commit 6a86cbc

File tree

212 files changed

+54458
-5753
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

212 files changed

+54458
-5753
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,16 @@ build/macosx/dist/*.tar.gz
2929
build/macosx/dist/*.tar.bz2
3030
build/macosx/libastylej*
3131
build/macosx/appbundler*.jar
32+
build/macosx/appbundler*.zip
33+
build/macosx/appbundler
34+
build/macosx/appbundler-1.0ea-arduino2
3235
build/linux/work/
3336
build/linux/dist/*.tar.gz
3437
build/linux/dist/*.tar.bz2
3538
build/linux/*.tgz
3639
build/linux/*.zip
3740
build/linux/libastylej*
41+
build/shared/reference*.zip
3842
test-bin
3943
*.iml
4044
.idea

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ board and a development environment that implements the Processing/Wiring
66
language. Arduino can be used to develop stand-alone interactive objects or
77
can be connected to software on your computer (e.g. Flash, Processing, MaxMSP).
88
The boards can be assembled by hand or purchased preassembled; the open-source
9-
IDE can be downloaded for free.
9+
IDE can be downloaded for free at http://arduino.cc/en/Main/Software
1010

1111
* For more information, see the website at: http://www.arduino.cc/
12-
or the forums at: http://arduino.cc/forum/
12+
or the forums at: http://arduino.cc/forum/
13+
You can also follow Arduino on twitter at: https://twitter.com/arduino or like Arduino on Facebook at: https://www.facebook.com/official.arduino
1314

1415
* To report a *bug* in the software or to request *a simple enhancement* go to:
1516
http://github.com/arduino/Arduino/issues

app/build.xml

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103

104104
<junit printsummary="yes" dir="${work.dir}" fork="true">
105105
<jvmarg value="-Djava.library.path=${java.additional.library.path}"/>
106+
<jvmarg value="-DWORK_DIR=."/>
106107
<classpath>
107108
<pathelement location="bin"/>
108109
<pathelement location="test-bin"/>

app/lib/apple.jar

7.35 KB
Binary file not shown.

app/src/processing/app/Base.java

+40-38
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,11 @@
2222

2323
package processing.app;
2424

25-
import java.awt.*;
26-
import java.awt.event.*;
27-
import java.io.*;
28-
import java.util.*;
29-
import java.util.List;
30-
31-
import javax.swing.*;
32-
3325
import cc.arduino.packages.DiscoveryManager;
3426
import processing.app.debug.TargetBoard;
3527
import processing.app.debug.TargetPackage;
3628
import processing.app.debug.TargetPlatform;
37-
import processing.app.helpers.CommandlineParser;
38-
import processing.app.helpers.FileUtils;
39-
import processing.app.helpers.GUIUserNotifier;
40-
import processing.app.helpers.OSUtils;
41-
import processing.app.helpers.PreferencesMap;
29+
import processing.app.helpers.*;
4230
import processing.app.helpers.filefilters.OnlyDirs;
4331
import processing.app.helpers.filefilters.OnlyFilesWithExtension;
4432
import processing.app.javax.swing.filechooser.FileNameExtensionFilter;
@@ -48,6 +36,14 @@
4836
import processing.app.packages.LibraryList;
4937
import processing.app.tools.MenuScroller;
5038
import processing.app.tools.ZipDeflater;
39+
40+
import javax.swing.*;
41+
import java.awt.*;
42+
import java.awt.event.*;
43+
import java.io.*;
44+
import java.util.*;
45+
import java.util.List;
46+
5147
import static processing.app.I18n._;
5248

5349

@@ -186,7 +182,6 @@ static protected void initRequirements() {
186182
try {
187183
Class.forName("com.sun.jdi.VirtualMachine");
188184
} catch (ClassNotFoundException cnfe) {
189-
showPlatforms();
190185
showError(_("Please install JDK 1.5 or later"),
191186
_("Arduino requires a full JDK (not just a JRE)\n" +
192187
"to run. Please install JDK 1.5 or later.\n" +
@@ -661,21 +656,30 @@ public void handleOpenReplace(File file) {
661656
*/
662657
public void handleOpenPrompt() throws Exception {
663658
// get the frontmost window frame for placing file dialog
664-
JFileChooser fd = new JFileChooser(Preferences.get("last.folder", getSketchbookFolder().getAbsolutePath()));
665-
fd.setDialogTitle(_("Open an Arduino sketch..."));
666-
fd.setFileSelectionMode(JFileChooser.FILES_ONLY);
667-
fd.setFileFilter(new FileNameExtensionFilter(_("Sketches (*.ino, *.pde)"), "ino", "pde"));
659+
FileDialog fd = new FileDialog(activeEditor, _("Open an Arduino sketch..."), FileDialog.LOAD);
660+
File lastFolder = new File(Preferences.get("last.folder", getSketchbookFolder().getAbsolutePath()));
661+
if (lastFolder.exists() && lastFolder.isFile()) {
662+
lastFolder = lastFolder.getParentFile();
663+
}
664+
fd.setDirectory(lastFolder.getAbsolutePath());
665+
666+
// Only show .pde files as eligible bachelors
667+
fd.setFilenameFilter(new FilenameFilter() {
668+
public boolean accept(File dir, String name) {
669+
return name.toLowerCase().endsWith(".ino")
670+
|| name.toLowerCase().endsWith(".pde");
671+
}
672+
});
668673

669-
Dimension preferredSize = fd.getPreferredSize();
670-
fd.setPreferredSize(new Dimension(preferredSize.width + 200, preferredSize.height + 200));
674+
fd.setVisible(true);
671675

672-
int returnVal = fd.showOpenDialog(activeEditor);
676+
String directory = fd.getDirectory();
677+
String filename = fd.getFile();
673678

674-
if (returnVal != JFileChooser.APPROVE_OPTION) {
675-
return;
676-
}
679+
// User canceled selection
680+
if (filename == null) return;
677681

678-
File inputFile = fd.getSelectedFile();
682+
File inputFile = new File(directory, filename);
679683

680684
Preferences.set("last.folder", inputFile.getAbsolutePath());
681685
handleOpen(inputFile);
@@ -1188,6 +1192,7 @@ public void actionPerformed(ActionEvent actionevent) {
11881192
Action subAction = new AbstractAction(_(boardCustomMenu.get(customMenuOption))) {
11891193
public void actionPerformed(ActionEvent e) {
11901194
Preferences.set("custom_" + menuId, ((TargetBoard)getValue("board")).getId() + "_" + getValue("custom_menu_option"));
1195+
onBoardOrPortChange();
11911196
}
11921197
};
11931198
subAction.putValue("board", board);
@@ -1901,43 +1906,40 @@ static public void registerWindowCloseKeys(JRootPane root,
19011906

19021907

19031908
static public void showReference(String filename) {
1904-
File referenceFolder = getContentFile("reference");
1909+
File referenceFolder = getContentFile("reference/arduino.cc/en");
19051910
File referenceFile = new File(referenceFolder, filename);
1911+
if (!referenceFile.exists())
1912+
referenceFile = new File(referenceFolder, filename + ".html");
19061913
openURL(referenceFile.getAbsolutePath());
19071914
}
19081915

19091916
static public void showGettingStarted() {
19101917
if (OSUtils.isMacOS()) {
1911-
showReference(_("Guide_MacOSX.html"));
1918+
showReference("Guide/MacOSX");
19121919
} else if (OSUtils.isWindows()) {
1913-
showReference(_("Guide_Windows.html"));
1920+
showReference("Guide/Windows");
19141921
} else {
1915-
openURL(_("http://www.arduino.cc/playground/Learning/Linux"));
1922+
openURL("http://www.arduino.cc/playground/Learning/Linux");
19161923
}
19171924
}
19181925

19191926
static public void showReference() {
1920-
showReference(_("index.html"));
1927+
showReference("Reference/HomePage");
19211928
}
19221929

19231930

19241931
static public void showEnvironment() {
1925-
showReference(_("Guide_Environment.html"));
1926-
}
1927-
1928-
1929-
static public void showPlatforms() {
1930-
showReference(_("environment") + File.separator + _("platforms.html"));
1932+
showReference("Guide/Environment");
19311933
}
19321934

19331935

19341936
static public void showTroubleshooting() {
1935-
showReference(_("Guide_Troubleshooting.html"));
1937+
showReference("Guide/Troubleshooting");
19361938
}
19371939

19381940

19391941
static public void showFAQ() {
1940-
showReference(_("FAQ.html"));
1942+
showReference("Main/FAQ");
19411943
}
19421944

19431945

app/src/processing/app/Editor.java

+56-17
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import com.jcraft.jsch.JSchException;
2828

29+
import jssc.SerialPortException;
2930
import processing.app.debug.*;
3031
import processing.app.forms.PasswordAuthorizationDialog;
3132
import processing.app.helpers.OSUtils;
@@ -60,6 +61,9 @@
6061
@SuppressWarnings("serial")
6162
public class Editor extends JFrame implements RunnerListener {
6263

64+
private final static List<String> BOARD_PROTOCOLS_ORDER = Arrays.asList(new String[]{"serial", "network"});
65+
private final static List<String> BOARD_PROTOCOLS_ORDER_TRANSLATIONS = Arrays.asList(new String[]{_("Serial ports"), _("Network ports")});
66+
6367
Base base;
6468

6569
// otherwise, if the window is resized with the message label
@@ -441,7 +445,7 @@ protected void applyPreferences() {
441445
textarea.setEditable(!external);
442446
saveMenuItem.setEnabled(!external);
443447
saveAsMenuItem.setEnabled(!external);
444-
448+
445449
textarea.setDisplayLineNumbers(Preferences.getBoolean("editor.linenumbers"));
446450

447451
TextAreaPainter painter = textarea.getPainter();
@@ -964,13 +968,17 @@ protected void selectSerialPort(String name) {
964968
}
965969
JCheckBoxMenuItem selection = null;
966970
for (int i = 0; i < serialMenu.getItemCount(); i++) {
967-
JCheckBoxMenuItem item = ((JCheckBoxMenuItem)serialMenu.getItem(i));
968-
if (item == null) {
971+
JMenuItem menuItem = serialMenu.getItem(i);
972+
if (!(menuItem instanceof JCheckBoxMenuItem)) {
973+
continue;
974+
}
975+
JCheckBoxMenuItem checkBoxMenuItem = ((JCheckBoxMenuItem) menuItem);
976+
if (checkBoxMenuItem == null) {
969977
System.out.println(_("name is null"));
970978
continue;
971979
}
972-
item.setState(false);
973-
if (name.equals(item.getText())) selection = item;
980+
checkBoxMenuItem.setState(false);
981+
if (name.equals(checkBoxMenuItem.getText())) selection = checkBoxMenuItem;
974982
}
975983
if (selection != null) selection.setState(true);
976984
//System.out.println(item.getLabel());
@@ -996,7 +1004,32 @@ protected void populatePortMenu() {
9961004
String selectedPort = Preferences.get("serial.port");
9971005

9981006
List<BoardPort> ports = Base.getDiscoveryManager().discovery();
1007+
1008+
ports = Base.getPlatform().filterPorts(ports, Preferences.getBoolean("serial.ports.showall"));
1009+
1010+
Collections.sort(ports, new Comparator<BoardPort>() {
1011+
@Override
1012+
public int compare(BoardPort o1, BoardPort o2) {
1013+
return BOARD_PROTOCOLS_ORDER.indexOf(o1.getProtocol()) - BOARD_PROTOCOLS_ORDER.indexOf(o2.getProtocol());
1014+
}
1015+
});
1016+
1017+
String lastProtocol = null;
1018+
String lastProtocolTranslated;
9991019
for (BoardPort port : ports) {
1020+
if (lastProtocol == null || !port.getProtocol().equals(lastProtocol)) {
1021+
if (lastProtocol != null) {
1022+
serialMenu.addSeparator();
1023+
}
1024+
lastProtocol = port.getProtocol();
1025+
1026+
if (BOARD_PROTOCOLS_ORDER.indexOf(port.getProtocol()) != -1) {
1027+
lastProtocolTranslated = BOARD_PROTOCOLS_ORDER_TRANSLATIONS.get(BOARD_PROTOCOLS_ORDER.indexOf(port.getProtocol()));
1028+
} else {
1029+
lastProtocolTranslated = port.getProtocol();
1030+
}
1031+
serialMenu.add(new JMenuItem(_(lastProtocolTranslated)));
1032+
}
10001033
String address = port.getAddress();
10011034
String label = port.getLabel();
10021035

@@ -1332,6 +1365,7 @@ public UndoAction() {
13321365
public void actionPerformed(ActionEvent e) {
13331366
try {
13341367
undo.undo();
1368+
sketch.setModified(true);
13351369
} catch (CannotUndoException ex) {
13361370
//System.out.println("Unable to undo: " + ex);
13371371
//ex.printStackTrace();
@@ -1353,17 +1387,11 @@ protected void updateUndoState() {
13531387
undoItem.setEnabled(true);
13541388
undoItem.setText(undo.getUndoPresentationName());
13551389
putValue(Action.NAME, undo.getUndoPresentationName());
1356-
if (sketch != null) {
1357-
sketch.setModified(true); // 0107
1358-
}
13591390
} else {
13601391
this.setEnabled(false);
13611392
undoItem.setEnabled(false);
13621393
undoItem.setText(_("Undo"));
13631394
putValue(Action.NAME, "Undo");
1364-
if (sketch != null) {
1365-
sketch.setModified(false); // 0107
1366-
}
13671395
}
13681396
}
13691397
}
@@ -1378,6 +1406,7 @@ public RedoAction() {
13781406
public void actionPerformed(ActionEvent e) {
13791407
try {
13801408
undo.redo();
1409+
sketch.setModified(true);
13811410
} catch (CannotRedoException ex) {
13821411
//System.out.println("Unable to redo: " + ex);
13831412
//ex.printStackTrace();
@@ -1646,7 +1675,7 @@ protected void setCode(SketchCodeDocument codeDoc) {
16461675
if (document == null) { // this document not yet inited
16471676
document = new SyntaxDocument();
16481677
codeDoc.setDocument(document);
1649-
1678+
16501679
// turn on syntax highlighting
16511680
document.setTokenMarker(new PdeKeywords());
16521681

@@ -1664,10 +1693,12 @@ protected void setCode(SketchCodeDocument codeDoc) {
16641693
document.addUndoableEditListener(new UndoableEditListener() {
16651694
public void undoableEditHappened(UndoableEditEvent e) {
16661695
if (compoundEdit != null) {
1667-
compoundEdit.addEdit(e.getEdit());
1668-
1696+
compoundEdit.addEdit(new CaretAwareUndoableEdit(e.getEdit(), textarea));
16691697
} else if (undo != null) {
16701698
undo.addEdit(new CaretAwareUndoableEdit(e.getEdit(), textarea));
1699+
}
1700+
if (compoundEdit != null || undo != null) {
1701+
sketch.setModified(true);
16711702
undoAction.updateUndoState();
16721703
redoAction.updateRedoState();
16731704
}
@@ -1870,7 +1901,7 @@ protected String getCurrentKeyword() {
18701901

18711902
} catch (BadLocationException bl) {
18721903
bl.printStackTrace();
1873-
}
1904+
}
18741905
return text;
18751906
}
18761907

@@ -1881,7 +1912,7 @@ protected void handleFindReference() {
18811912
if (referenceFile == null) {
18821913
statusNotice(I18n.format(_("No reference available for \"{0}\""), text));
18831914
} else {
1884-
Base.showReference(I18n.format(_("{0}.html"), referenceFile));
1915+
Base.showReference("Reference/" + referenceFile);
18851916
}
18861917
}
18871918

@@ -2025,6 +2056,8 @@ protected boolean checkModified() {
20252056
// As of Processing 1.0.10, this always happens immediately.
20262057
// http://dev.processing.org/bugs/show_bug.cgi?id=1456
20272058

2059+
toFront();
2060+
20282061
String prompt = I18n.format(_("Save changes to \"{0}\"? "), sketch.getName());
20292062

20302063
if (!OSUtils.isMacOS()) {
@@ -2177,7 +2210,7 @@ protected boolean handleOpenInternal(File sketchFile) {
21772210
// copy the sketch inside
21782211
File properPdeFile = new File(properFolder, sketchFile.getName());
21792212
try {
2180-
Base.copyFile(file, properPdeFile);
2213+
Base.copyFile(sketchFile, properPdeFile);
21812214
} catch (IOException e) {
21822215
Base.showWarning(_("Error"), _("Could not copy to a proper location."), e);
21832216
return false;
@@ -2538,6 +2571,12 @@ public void handleSerial() {
25382571
statusError(_("Unable to connect: is the sketch using the bridge?"));
25392572
} catch (JSchException e) {
25402573
statusError(_("Unable to connect: wrong password?"));
2574+
} catch (SerialException e) {
2575+
String errorMessage = e.getMessage();
2576+
if (e.getCause() != null && e.getCause() instanceof SerialPortException) {
2577+
errorMessage += " (" + ((SerialPortException) e.getCause()).getExceptionType() + ")";
2578+
}
2579+
statusError(errorMessage);
25412580
} catch (Exception e) {
25422581
statusError(e);
25432582
} finally {

0 commit comments

Comments
 (0)