Skip to content

Commit 2778651

Browse files
committed
Allow multiple boards to share the same menu
This stuff is truly madness, should be refactored from the ground up by a Java expert
1 parent 06cfbbf commit 2778651

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

app/src/processing/app/Base.java

+10-3
Original file line numberDiff line numberDiff line change
@@ -1539,11 +1539,16 @@ public void actionPerformed(ActionEvent actionevent) {
15391539
@SuppressWarnings("serial")
15401540
Action subAction = new AbstractAction(tr(boardCustomMenu.get(customMenuOption))) {
15411541
public void actionPerformed(ActionEvent e) {
1542-
PreferencesData.set("custom_" + menuId, ((TargetBoard) getValue("board")).getId() + "_" + getValue("custom_menu_option"));
1542+
PreferencesData.set("custom_" + menuId, ((List<TargetBoard>) getValue("board")).get(0).getId() + "_" + getValue("custom_menu_option"));
15431543
onBoardOrPortChange();
15441544
}
15451545
};
1546-
subAction.putValue("board", board);
1546+
List<TargetBoard> boards = (List<TargetBoard>) subAction.getValue("board");
1547+
if (boards == null) {
1548+
boards = new ArrayList<TargetBoard>();
1549+
}
1550+
boards.add(board);
1551+
subAction.putValue("board", boards);
15471552
subAction.putValue("custom_menu_option", customMenuOption);
15481553

15491554
if (!buttonGroupsMap.containsKey(menuId)) {
@@ -1571,7 +1576,9 @@ private void filterVisibilityOfSubsequentBoardMenus(List<JMenu> boardsCustomMenu
15711576
JMenu menu = boardsCustomMenus.get(i);
15721577
for (int m = 0; m < menu.getItemCount(); m++) {
15731578
JMenuItem menuItem = menu.getItem(m);
1574-
menuItem.setVisible(menuItem.getAction().getValue("board").equals(board));
1579+
for (TargetBoard t_board : (List<TargetBoard>)menuItem.getAction().getValue("board")) {
1580+
menuItem.setVisible(t_board.equals(board));
1581+
}
15751582
}
15761583
menu.setVisible(ifThereAreVisibleItemsOn(menu));
15771584

0 commit comments

Comments
 (0)