Skip to content

Commit afc7fc6

Browse files
committed
Merge branch 'ide-1.5.x' into scheduler
2 parents d9c6e10 + 70351fc commit afc7fc6

File tree

11 files changed

+256
-231
lines changed

11 files changed

+256
-231
lines changed

app/src/processing/app/Base.java

Lines changed: 78 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public class Base {
113113
Editor activeEditor;
114114

115115

116-
static public void main(String args[]) {
116+
static public void main(String args[]) throws Exception {
117117
try {
118118
File versionFile = getContentFile("lib/version.txt");
119119
if (versionFile.exists()) {
@@ -244,7 +244,7 @@ static protected void initRequirements() {
244244
}
245245

246246

247-
public Base(String[] args) {
247+
public Base(String[] args) throws Exception {
248248
platform.init(this);
249249

250250
// Get the sketchbook path, and make sure it's set properly
@@ -280,11 +280,28 @@ public Base(String[] args) {
280280
// Setup board-dependent variables.
281281
onBoardOrPortChange();
282282

283-
// Check if there were previously opened sketches to be restored
284-
boolean opened = restoreSketches();
285-
283+
boolean opened = false;
284+
boolean doUpload = false;
285+
String selectBoard = null;
286+
String selectPort = null;
286287
// Check if any files were passed in on the command line
287288
for (int i = 0; i < args.length; i++) {
289+
if (args[i].equals("--upload")) {
290+
doUpload = true;
291+
continue;
292+
}
293+
if (args[i].equals("--board")) {
294+
i++;
295+
if (i < args.length)
296+
selectBoard = args[i];
297+
continue;
298+
}
299+
if (args[i].equals("--port")) {
300+
i++;
301+
if (i < args.length)
302+
selectPort = args[i];
303+
continue;
304+
}
288305
String path = args[i];
289306
// Fix a problem with systems that use a non-ASCII languages. Paths are
290307
// being passed in with 8.3 syntax, which makes the sketch loader code
@@ -303,6 +320,23 @@ public Base(String[] args) {
303320
}
304321
}
305322

323+
if (doUpload) {
324+
if (!opened)
325+
throw new Exception(_("Can't open source sketch!"));
326+
Thread.sleep(2000);
327+
Editor editor = editors.get(0);
328+
if (selectPort != null)
329+
editor.selectSerialPort(selectPort);
330+
if (selectBoard != null)
331+
selectBoard(selectBoard, editor);
332+
editor.exportHandler.run();
333+
System.exit(0);
334+
}
335+
336+
// Check if there were previously opened sketches to be restored
337+
if (restoreSketches())
338+
opened = true;
339+
306340
// Create a new empty window (will be replaced with any files to be opened)
307341
if (!opened) {
308342
handleNew();
@@ -1124,7 +1158,7 @@ public void onBoardOrPortChange() {
11241158
}
11251159

11261160
public void rebuildBoardsMenu(JMenu toolsMenu, final Editor editor) {
1127-
JMenu boardsMenu = makeOrGetBoardMenu(toolsMenu, "Board");
1161+
JMenu boardsMenu = makeOrGetBoardMenu(toolsMenu, _("Board"));
11281162

11291163
String selPackage = Preferences.get("target_package");
11301164
String selPlatform = Preferences.get("target_platform");
@@ -1161,37 +1195,22 @@ public void rebuildBoardsMenu(JMenu toolsMenu, final Editor editor) {
11611195

11621196
// For every platform cycle through all boards
11631197
for (final String boardID : targetPlatform.getBoards().keySet()) {
1164-
1165-
PreferencesMap boardAttributes = boards.get(boardID);
1166-
1167-
AbstractAction action = new AbstractAction(boardAttributes.get("name")) {
1168-
1169-
@Override
1170-
public void actionPerformed(ActionEvent e) {
1171-
Preferences.set("target_package", (String) getValue("package"));
1172-
Preferences.set("target_platform", (String) getValue("platform"));
1173-
Preferences.set("board", (String) getValue("board"));
1174-
1175-
filterVisibilityOfSubsequentBoardMenus((String) getValue("board"), 1, e);
1176-
1177-
onBoardOrPortChange();
1178-
Sketch.buildSettingChanged();
1179-
rebuildImportMenu(Editor.importMenu, editor);
1180-
rebuildExamplesMenu(Editor.examplesMenu);
1198+
// Setup a menu item for the current board
1199+
String boardName = boards.get(boardID).get("name");
1200+
@SuppressWarnings("serial")
1201+
Action action = new AbstractAction(boardName) {
1202+
public void actionPerformed(ActionEvent actionevent) {
1203+
selectBoard((String) getValue("b"), editor);
11811204
}
1182-
11831205
};
1184-
action.putValue("properties", boardAttributes);
1185-
action.putValue("board", boardID);
1186-
action.putValue("package", packageName);
1187-
action.putValue("platform", platformName);
1206+
action.putValue("b", packageName + ":" + platformName + ":" + boardID);
11881207

11891208
JRadioButtonMenuItem item = new JRadioButtonMenuItem(action);
11901209
boardsMenu.add(item);
11911210
boardsButtonGroup.add(item);
11921211

1193-
if (selBoard.equals(action.getValue("board")) && selPackage.equals(action.getValue("package"))
1194-
&& selPlatform.equals(action.getValue("platform"))) {
1212+
if (selBoard.equals(boardID) && selPackage.equals(packageName)
1213+
&& selPlatform.equals(platformName)) {
11951214
menuItemsToClickAfterStartup.add(item);
11961215
}
11971216

@@ -1205,34 +1224,33 @@ public void actionPerformed(ActionEvent e) {
12051224
MapWithSubkeys boardCustomMenu = customMenu.get(boardID);
12061225
final int currentIndex = i + 1 + 1; //plus 1 to skip the first board menu, plus 1 to keep the custom menu next to this one
12071226
for (final String customMenuOption : boardCustomMenu.getKeys()) {
1208-
action = new AbstractAction(_(boardCustomMenu.getValueOf(customMenuOption))) {
1209-
1227+
@SuppressWarnings("serial")
1228+
Action subAction = new AbstractAction(_(boardCustomMenu.getValueOf(customMenuOption))) {
12101229
@Override
12111230
public void actionPerformed(ActionEvent e) {
12121231
Preferences.set("target_package", (String) getValue("package"));
12131232
Preferences.set("target_platform", (String) getValue("platform"));
12141233
Preferences.set("board", (String) getValue("board"));
12151234
Preferences.set("custom_" + customMenuID, boardID + "_" + (String) getValue("custom_menu_option"));
12161235

1217-
filterVisibilityOfSubsequentBoardMenus((String) getValue("board"), currentIndex, e);
1236+
filterVisibilityOfSubsequentBoardMenus((String) getValue("board"), currentIndex);
12181237

12191238
onBoardOrPortChange();
12201239
Sketch.buildSettingChanged();
12211240
rebuildImportMenu(Editor.importMenu, editor);
12221241
rebuildExamplesMenu(Editor.examplesMenu);
12231242
}
12241243
};
1225-
action.putValue("properties", boardCustomMenu.getValues());
1226-
action.putValue("board", boardID);
1227-
action.putValue("custom_menu_option", customMenuOption);
1228-
action.putValue("package", packageName);
1229-
action.putValue("platform", platformName);
1244+
subAction.putValue("board", boardID);
1245+
subAction.putValue("custom_menu_option", customMenuOption);
1246+
subAction.putValue("package", packageName);
1247+
subAction.putValue("platform", platformName);
12301248

12311249
if (!buttonGroupsMap.containsKey(customMenuID)) {
12321250
buttonGroupsMap.put(customMenuID, new ButtonGroup());
12331251
}
12341252

1235-
item = new JRadioButtonMenuItem(action);
1253+
item = new JRadioButtonMenuItem(subAction);
12361254
menu.add(item);
12371255
buttonGroupsMap.get(customMenuID).add(item);
12381256

@@ -1258,7 +1276,7 @@ public void actionPerformed(ActionEvent e) {
12581276
}
12591277
}
12601278

1261-
private static void filterVisibilityOfSubsequentBoardMenus(String boardID, int fromIndex, ActionEvent originatingEvent) {
1279+
private static void filterVisibilityOfSubsequentBoardMenus(String boardID, int fromIndex) {
12621280
for (int i = fromIndex; i < Editor.boardsMenus.size(); i++) {
12631281
JMenu menu = Editor.boardsMenus.get(i);
12641282
for (int m = 0; m < menu.getItemCount(); m++) {
@@ -1271,7 +1289,7 @@ private static void filterVisibilityOfSubsequentBoardMenus(String boardID, int f
12711289
JMenuItem visibleSelectedOrFirstMenuItem = selectVisibleSelectedOrFirstMenuItem(menu);
12721290
if (!visibleSelectedOrFirstMenuItem.isSelected()) {
12731291
visibleSelectedOrFirstMenuItem.setSelected(true);
1274-
visibleSelectedOrFirstMenuItem.getAction().actionPerformed(originatingEvent);
1292+
visibleSelectedOrFirstMenuItem.getAction().actionPerformed(null);
12751293
}
12761294
}
12771295
}
@@ -1287,13 +1305,12 @@ private static boolean ifThereAreVisibleItemsOn(JMenu menu) {
12871305
}
12881306

12891307
private JMenu makeOrGetBoardMenu(JMenu toolsMenu, String label) {
1290-
String i18nLabel = _(label);
12911308
for (JMenu menu : Editor.boardsMenus) {
1292-
if (i18nLabel.equals(menu.getText())) {
1309+
if (label.equals(menu.getText())) {
12931310
return menu;
12941311
}
12951312
}
1296-
JMenu menu = new JMenu(i18nLabel);
1313+
JMenu menu = new JMenu(label);
12971314
Editor.boardsMenus.add(menu);
12981315
toolsMenu.add(menu);
12991316
return menu;
@@ -1329,7 +1346,23 @@ private static JMenuItem selectFirstEnabledMenuItem(JMenu menu) {
13291346
}
13301347
throw new IllegalStateException("Menu has no enabled items");
13311348
}
1332-
1349+
1350+
1351+
private void selectBoard(String selectBoard, Editor editor) {
1352+
String[] split = selectBoard.split(":");
1353+
Preferences.set("target_package", split[0]);
1354+
Preferences.set("target_platform", split[1]);
1355+
Preferences.set("board", split[2]);
1356+
1357+
filterVisibilityOfSubsequentBoardMenus(split[2], 1);
1358+
1359+
onBoardOrPortChange();
1360+
Sketch.buildSettingChanged();
1361+
rebuildImportMenu(Editor.importMenu, editor);
1362+
rebuildExamplesMenu(Editor.examplesMenu);
1363+
}
1364+
1365+
13331366
public void rebuildProgrammerMenu(JMenu menu) {
13341367
menu.removeAll();
13351368
ButtonGroup group = new ButtonGroup();

app/src/processing/app/debug/Compiler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
public class Compiler implements MessageConsumer {
4646
static final String BUGS_URL =
47-
_("http://code.google.com/p/arduino/issues/list");
47+
_("http://github.com/arduino/Arduino/issues");
4848
static final String SUPER_BADNESS =
4949
I18n.format(_("Compiler error, please submit this code to {0}"), BUGS_URL);
5050

app/src/processing/app/debug/TargetPlatform.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
*/
2424
package processing.app.debug;
2525

26+
import static processing.app.I18n._;
27+
2628
import java.io.File;
2729
import java.util.HashMap;
2830
import java.util.Map;
@@ -46,6 +48,12 @@ public TargetPlatform(String _name, File _folder) {
4648
programmers = new HashMap<String, PreferencesMap>();
4749
preferences = new PreferencesMap();
4850

51+
if (false) {
52+
// Hack to extract this word by gettext tool.
53+
// This word is actually defined in the "boards.txt".
54+
String notused = _("Processor");
55+
}
56+
4957
try {
5058
File boardsFile = new File(_folder, "boards.txt");
5159
if (boardsFile.exists()) {

hardware/arduino/sam/cores/arduino/USB/USBCore.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ static bool USBD_SendDescriptor(Setup& setup)
385385
if (USB_DEVICE_DESCRIPTOR_TYPE == t)
386386
{
387387
TRACE_CORE(puts("=> USBD_SendDescriptor : USB_DEVICE_DESCRIPTOR_TYPE\r\n");)
388-
if (setup.wLength >= 8)
388+
if (setup.wLength == 8)
389389
{
390390
_cdcComposite = 1;
391391
}

0 commit comments

Comments
 (0)