Skip to content

Commit

Permalink
Merge branch 'ide-1.5.x' into ide-1.5.x-java7
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed Jan 19, 2015
2 parents 7ea0575 + f4a6b62 commit 529e2ed
Show file tree
Hide file tree
Showing 186 changed files with 31,505 additions and 11,691 deletions.
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ hardware/arduino/bootloaders/caterina_LUFA/Caterina.eep
hardware/arduino/bootloaders/caterina_LUFA/.dep/
build/libastylej-*.zip
build/windows/work/
build/windows/jre.zip
build/windows/*.zip
build/windows/*.tgz
build/windows/libastylej*
build/windows/arduino-*.zip
build/windows/dist/gcc-*.tar.gz
build/windows/dist/*.tar.gz
build/windows/dist/*.tar.bz2
build/windows/launch4j-*
build/windows/launcher/launch4j
build/windows/WinAVR-*.zip
build/macosx/arduino-*.zip
build/macosx/dist/gcc-*.tar.gz
build/macosx/dist/*.tar.gz
build/macosx/dist/*.tar.bz2
build/macosx/libastylej*
build/macosx/appbundler*.jar
build/linux/work/
Expand Down
74 changes: 63 additions & 11 deletions app/src/processing/app/AbstractMonitor.java
Original file line number Diff line number Diff line change
@@ -1,31 +1,53 @@
package processing.app;

import processing.app.debug.MessageConsumer;
import processing.app.legacy.PApplet;
import static processing.app.I18n._;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.text.DefaultCaret;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import static processing.app.I18n._;
import javax.swing.AbstractAction;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
import javax.swing.border.EmptyBorder;
import javax.swing.text.DefaultCaret;

import processing.app.debug.TextAreaFIFO;
import processing.app.legacy.PApplet;

@SuppressWarnings("serial")
public abstract class AbstractMonitor extends JFrame implements MessageConsumer {
public abstract class AbstractMonitor extends JFrame implements ActionListener {

protected final JLabel noLineEndingAlert;
protected JTextArea textArea;
protected TextAreaFIFO textArea;
protected JScrollPane scrollPane;
protected JTextField textField;
protected JButton sendButton;
protected JCheckBox autoscrollBox;
protected JComboBox lineEndings;
protected JComboBox serialRates;

private Timer updateTimer;
private StringBuffer updateBuffer;

public AbstractMonitor(String title) {
super(title);

Expand Down Expand Up @@ -59,7 +81,9 @@ public void actionPerformed(ActionEvent event) {
Font editorFont = Preferences.getFont("editor.font");
Font font = new Font(consoleFont.getName(), consoleFont.getStyle(), editorFont.getSize());

textArea = new JTextArea(16, 40);
textArea = new TextAreaFIFO(8000000);
textArea.setRows(16);
textArea.setColumns(40);
textArea.setEditable(false);
textArea.setFont(font);

Expand Down Expand Up @@ -111,7 +135,7 @@ public void actionPerformed(ActionEvent event) {

String[] serialRateStrings = {
"300", "1200", "2400", "4800", "9600",
"19200", "57600", "115200"
"19200", "38400", "57600", "115200"
};

serialRates = new JComboBox();
Expand Down Expand Up @@ -149,6 +173,10 @@ public void actionPerformed(ActionEvent event) {
}
}
}

updateBuffer = new StringBuffer(1048576);
updateTimer = new Timer(33, this); // redraw serial monitor at 30 Hz
updateTimer.start();
}

public void onSerialRateChange(ActionListener listener) {
Expand Down Expand Up @@ -199,4 +227,28 @@ public String getAuthorizationKey() {
public abstract void open() throws Exception;

public abstract void close() throws Exception;

public synchronized void addToUpdateBuffer(char buff[], int n) {
updateBuffer.append(buff, 0, n);
}

private synchronized String consumeUpdateBuffer() {
String s = updateBuffer.toString();
updateBuffer.setLength(0);
return s;
}

public void actionPerformed(ActionEvent e) {
final String s = consumeUpdateBuffer();
if (s.length() > 0) {
//System.out.println("gui append " + s.length());
if (autoscrollBox.isSelected()) {
textArea.appendTrim(s);
textArea.setCaretPosition(textArea.getDocument().getLength());
} else {
textArea.appendNoTrim(s);
}
}
}

}
13 changes: 8 additions & 5 deletions app/src/processing/app/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,8 @@ public LibraryList getUserLibs() {
}

public void rebuildImportMenu(JMenu importMenu) {
if (importMenu == null)
return;
importMenu.removeAll();

JMenuItem addLibraryMenuItem = new JMenuItem(_("Add Library..."));
Expand Down Expand Up @@ -1035,6 +1037,8 @@ public void actionPerformed(ActionEvent e) {
}

public void rebuildExamplesMenu(JMenu menu) {
if (menu == null)
return;
try {
menu.removeAll();

Expand Down Expand Up @@ -1077,6 +1081,10 @@ public void onBoardOrPortChange() {
}

public void rebuildBoardsMenu(JMenu toolsMenu, Editor editor) throws Exception {
// If there are no platforms installed skip menu creation
if (BaseNoGui.packages.size() == 0)
return;

JMenu boardsMenu = getBoardCustomMenu();

boolean first = true;
Expand Down Expand Up @@ -1698,11 +1706,6 @@ static public PreferencesMap getBoardPreferences() {
return BaseNoGui.getBoardPreferences();
}

public static TargetBoard getTargetBoard() {
String boardId = Preferences.get("board");
return getTargetPlatform().getBoard(boardId);
}

static public File getPortableFolder() {
return BaseNoGui.getPortableFolder();
}
Expand Down
Loading

0 comments on commit 529e2ed

Please sign in to comment.