diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 036cb4f5a..2e3d7b346 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -993,6 +993,13 @@ public class Base { } + public void onBoardOrPortChange() { + for (Editor editor : editors) { + editor.onBoardOrPortChange(); + } + } + + public void rebuildBoardsMenu(JMenu menu) { //System.out.println("rebuilding boards menu"); menu.removeAll(); @@ -1005,6 +1012,7 @@ public class Base { //System.out.println("Switching to " + target + ":" + board); Preferences.set("target", (String) getValue("target")); Preferences.set("board", (String) getValue("board")); + onBoardOrPortChange(); } }; action.putValue("target", target.getName()); diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index c3547d87f..0733530ce 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -908,6 +908,7 @@ public class Editor extends JFrame implements RunnerListener { public void actionPerformed(ActionEvent e) { selectSerialPort(((JCheckBoxMenuItem)e.getSource()).getText()); + base.onBoardOrPortChange(); } /* @@ -2624,7 +2625,14 @@ public class Editor extends JFrame implements RunnerListener { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + protected void onBoardOrPortChange() { + Map boardPreferences = Base.getBoardPreferences(); + lineStatus.setBoardName(boardPreferences.get("name")); + lineStatus.setSerialPort(Preferences.get("serial.port")); + lineStatus.repaint(); + } + /** * Returns the edit popup menu. */ diff --git a/app/src/processing/app/EditorLineStatus.java b/app/src/processing/app/EditorLineStatus.java index f28175ff0..b4c49bdcc 100644 --- a/app/src/processing/app/EditorLineStatus.java +++ b/app/src/processing/app/EditorLineStatus.java @@ -25,6 +25,9 @@ package processing.app; import processing.app.syntax.*; import java.awt.*; +import java.awt.geom.Rectangle2D; +import java.util.Map; + import javax.swing.*; @@ -39,10 +42,14 @@ public class EditorLineStatus extends JComponent { Color foreground; Color background; + Color messageForeground; + Font font; int high; String text = ""; + String name = ""; + String serialport = ""; public EditorLineStatus(JEditTextArea textarea) { @@ -87,6 +94,11 @@ public class EditorLineStatus extends JComponent { public void paintComponent(Graphics g) { + if (name=="" && serialport=="") { + Map boardPreferences = Base.getBoardPreferences(); + setBoardName(boardPreferences.get("name")); + setSerialPort(Preferences.get("serial.port")); + } g.setColor(background); Dimension size = getSize(); g.fillRect(0, 0, size.width, size.height); @@ -96,11 +108,20 @@ public class EditorLineStatus extends JComponent { int baseline = (high + g.getFontMetrics().getAscent()) / 2; g.drawString(text, 6, baseline); + g.setColor(messageForeground); + String tmp = "board: " + name + " on " + serialport; + + Rectangle2D bounds = g.getFontMetrics().getStringBounds(tmp, null); + + g.drawString(tmp, size.width - (int) bounds.getWidth() -20 , baseline); + if (Base.isMacOS()) { g.drawImage(resize, size.width - 20, 0, this); } } + public void setBoardName(String name) { this.name = name; } + public void setSerialPort(String serialport) { this.serialport = serialport; } public Dimension getPreferredSize() { return new Dimension(300, high);