From 8c916928458a8368b847509356f8fd4de8a57569 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Tue, 7 Apr 2020 10:14:35 +0200 Subject: [PATCH] Boards Menu: add hint if core lives in sketchbook --- app/src/processing/app/Base.java | 4 ++++ .../src/processing/app/debug/LegacyTargetPlatform.java | 5 +++++ arduino-core/src/processing/app/debug/TargetPlatform.java | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 7af728fdd..34193e07d 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -1494,6 +1494,10 @@ public class Base { if (platformLabel == null) platformLabel = targetPackage.getId() + "-" + targetPlatform.getId(); + // add an hint that this core lives in sketchbook + if (targetPlatform.isInSketchbook()) + platformLabel += " (in sketchbook)"; + JMenu platformBoardsMenu = new JMenu(platformLabel); MenuScroller.setScrollerFor(platformBoardsMenu); platformMenus.add(platformBoardsMenu); diff --git a/arduino-core/src/processing/app/debug/LegacyTargetPlatform.java b/arduino-core/src/processing/app/debug/LegacyTargetPlatform.java index c00378c48..ad1030b8f 100644 --- a/arduino-core/src/processing/app/debug/LegacyTargetPlatform.java +++ b/arduino-core/src/processing/app/debug/LegacyTargetPlatform.java @@ -245,4 +245,9 @@ public class LegacyTargetPlatform implements TargetPlatform { res += " " + boardId + " = " + boards.get(boardId) + "\n"; return res + "}"; } + + @Override + public boolean isInSketchbook() { + return getFolder().getAbsolutePath().startsWith(BaseNoGui.getDefaultSketchbookFolder().getAbsolutePath()); + } } diff --git a/arduino-core/src/processing/app/debug/TargetPlatform.java b/arduino-core/src/processing/app/debug/TargetPlatform.java index 4b13cf87a..330b260bb 100644 --- a/arduino-core/src/processing/app/debug/TargetPlatform.java +++ b/arduino-core/src/processing/app/debug/TargetPlatform.java @@ -94,4 +94,10 @@ public interface TargetPlatform { */ public TargetPackage getContainerPackage(); + /** + * Returns true if the platform is installed in a subfolder of the sketchbook + * + * @return + */ + public boolean isInSketchbook(); }