1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-12-01 12:24:14 +01:00

Merge remote-tracking branch 'cmaglie/port-on-statusbar' into new-extension

This commit is contained in:
David A. Mellis 2011-08-24 11:46:18 -04:00
commit 365d4acf6e
3 changed files with 37 additions and 0 deletions

View File

@ -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());

View File

@ -908,6 +908,7 @@ public class Editor extends JFrame implements RunnerListener {
public void actionPerformed(ActionEvent e) {
selectSerialPort(((JCheckBoxMenuItem)e.getSource()).getText());
base.onBoardOrPortChange();
}
/*
@ -2624,6 +2625,13 @@ public class Editor extends JFrame implements RunnerListener {
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
protected void onBoardOrPortChange() {
Map<String, String> boardPreferences = Base.getBoardPreferences();
lineStatus.setBoardName(boardPreferences.get("name"));
lineStatus.setSerialPort(Preferences.get("serial.port"));
lineStatus.repaint();
}
/**
* Returns the edit popup menu.

View File

@ -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<String, String> 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);