mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-30 16:24:09 +03:00
svn merge -r 72:HEAD svn+ssh://mellis@svn.berlios.de/svnroot/repos/arduino/tags/0004 - used Base.java from tags/0004 but changed version back to 0003.
This commit is contained in:
2226
app/Base.java
2226
app/Base.java
File diff suppressed because it is too large
Load Diff
@ -24,7 +24,7 @@
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
$Id:$
|
||||
$Id$
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
135
app/Editor.java
135
app/Editor.java
@ -82,7 +82,7 @@ public class Editor extends JFrame
|
||||
EditorHeader header;
|
||||
EditorStatus status;
|
||||
EditorConsole console;
|
||||
|
||||
Serial serialPort;
|
||||
JSplitPane splitPane;
|
||||
JPanel consolePanel;
|
||||
|
||||
@ -107,12 +107,13 @@ public class Editor extends JFrame
|
||||
JMenuItem saveMenuItem;
|
||||
JMenuItem saveAsMenuItem;
|
||||
|
||||
|
||||
//ButtonGroup serialGroup;
|
||||
JMenu serialSubMenu;
|
||||
JMenu serialRateSubMenu;
|
||||
SerialMenuListener serialMenuListener;
|
||||
|
||||
//
|
||||
|
||||
boolean debugging;
|
||||
boolean running;
|
||||
boolean presenting;
|
||||
|
||||
@ -655,9 +656,10 @@ public class Editor extends JFrame
|
||||
JMenuItem item;
|
||||
JMenuItem rbMenuItem;
|
||||
JMenuItem cbMenuItem;
|
||||
SerialMenuListener sml = new SerialMenuListener();
|
||||
SerialRateMenuListener srml = new SerialRateMenuListener();
|
||||
// Enumeration portRates = {"9600","19200","38400","57600","115200"};
|
||||
|
||||
serialMenuListener = new SerialMenuListener();
|
||||
|
||||
JMenu menu = new JMenu("Tools");
|
||||
|
||||
@ -675,55 +677,17 @@ public class Editor extends JFrame
|
||||
|
||||
serialSubMenu = new JMenu("Serial port");
|
||||
|
||||
item = newJMenuItem("Update List", 'E', false);
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// if (debug) displayResult("Serial Port List Updated");
|
||||
//updateSerial();
|
||||
}
|
||||
});
|
||||
// item = newJMenuItem("Update List", 'E', false);
|
||||
// item.addActionListener(new ActionListener() {
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// // if (debug) displayResult("Serial Port List Updated");
|
||||
// //updateSerial();
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ButtonGroup group = new ButtonGroup();
|
||||
|
||||
|
||||
// getting list of ports
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
for (Enumeration enumeration = CommPortIdentifier.getPortIdentifiers(); enumeration.hasMoreElements();)
|
||||
{
|
||||
CommPortIdentifier commportidentifier = (CommPortIdentifier)enumeration.nextElement();
|
||||
if (commportidentifier.getPortType() == CommPortIdentifier.PORT_SERIAL)
|
||||
{
|
||||
String curr_port = commportidentifier.getName();
|
||||
rbMenuItem = new JCheckBoxMenuItem(curr_port, curr_port.equals(Preferences.get("serial.port")));
|
||||
rbMenuItem.addActionListener(sml);
|
||||
group.add(rbMenuItem);
|
||||
serialSubMenu.add(rbMenuItem);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
catch (Exception exception)
|
||||
{
|
||||
System.out.println("error retrieving port list");
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
if (serialSubMenu.getItemCount() == 0) {
|
||||
serialSubMenu.setEnabled(false);
|
||||
}
|
||||
|
||||
//serialSubMenu.addSeparator();
|
||||
//serialSubMenu.add(item);
|
||||
|
||||
menu.add(serialSubMenu);
|
||||
//serialGroup = new ButtonGroup();
|
||||
populateSerialMenu();
|
||||
menu.add(serialSubMenu);
|
||||
|
||||
// End of The serial options
|
||||
|
||||
@ -735,7 +699,7 @@ public class Editor extends JFrame
|
||||
|
||||
//serialSubMenu.add(item);
|
||||
//serialSubMenu.addSeparator();
|
||||
group = new ButtonGroup();
|
||||
ButtonGroup group = new ButtonGroup();
|
||||
|
||||
int curr_rate = Preferences.getInteger("serial.download_rate");
|
||||
|
||||
@ -755,9 +719,55 @@ public class Editor extends JFrame
|
||||
serialRateSubMenu.add(rbMenuItem);
|
||||
|
||||
menu.add(serialRateSubMenu);
|
||||
|
||||
menu.addMenuListener(new MenuListener() {
|
||||
public void menuCanceled(MenuEvent e) {}
|
||||
public void menuDeselected(MenuEvent e) {}
|
||||
public void menuSelected(MenuEvent e) {
|
||||
populateSerialMenu();
|
||||
}
|
||||
});
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
protected void populateSerialMenu() {
|
||||
// getting list of ports
|
||||
|
||||
JMenuItem rbMenuItem;
|
||||
|
||||
serialSubMenu.removeAll();
|
||||
|
||||
try
|
||||
{
|
||||
for (Enumeration enumeration = CommPortIdentifier.getPortIdentifiers(); enumeration.hasMoreElements();)
|
||||
{
|
||||
CommPortIdentifier commportidentifier = (CommPortIdentifier)enumeration.nextElement();
|
||||
if (commportidentifier.getPortType() == CommPortIdentifier.PORT_SERIAL)
|
||||
{
|
||||
String curr_port = commportidentifier.getName();
|
||||
rbMenuItem = new JCheckBoxMenuItem(curr_port, curr_port.equals(Preferences.get("serial.port")));
|
||||
rbMenuItem.addActionListener(serialMenuListener);
|
||||
//serialGroup.add(rbMenuItem);
|
||||
serialSubMenu.add(rbMenuItem);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
catch (Exception exception)
|
||||
{
|
||||
System.out.println("error retrieving port list");
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
if (serialSubMenu.getItemCount() == 0) {
|
||||
serialSubMenu.setEnabled(false);
|
||||
}
|
||||
|
||||
//serialSubMenu.addSeparator();
|
||||
//serialSubMenu.add(item);
|
||||
}
|
||||
|
||||
|
||||
protected JMenu buildHelpMenu() {
|
||||
@ -1292,6 +1302,17 @@ public class Editor extends JFrame
|
||||
}
|
||||
|
||||
|
||||
public void handleSerial() {
|
||||
if (!debugging) {
|
||||
console.clear();
|
||||
serialPort = new Serial(true);
|
||||
debugging = true;
|
||||
} else {
|
||||
doStop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void handleStop() { // called by menu or buttons
|
||||
if (presenting) {
|
||||
doClose();
|
||||
@ -1305,6 +1326,10 @@ public class Editor extends JFrame
|
||||
* Stop the applet but don't kill its window.
|
||||
*/
|
||||
public void doStop() {
|
||||
if (debugging) {
|
||||
serialPort.dispose();
|
||||
debugging = false;
|
||||
}
|
||||
if (runtime != null) runtime.stop();
|
||||
if (watcher != null) watcher.stop();
|
||||
message(EMPTY);
|
||||
@ -1695,8 +1720,8 @@ public class Editor extends JFrame
|
||||
* hitting export twice, quickly, and horking things up.
|
||||
*/
|
||||
synchronized public void handleExport() {
|
||||
//if(debugging)
|
||||
//doStop();
|
||||
if(debugging)
|
||||
doStop();
|
||||
console.clear();
|
||||
//String what = sketch.isLibrary() ? "Applet" : "Library";
|
||||
//message("Exporting " + what + "...");
|
||||
|
@ -37,7 +37,7 @@ import javax.swing.event.*;
|
||||
public class EditorButtons extends JComponent implements MouseInputListener {
|
||||
|
||||
static final String title[] = {
|
||||
"Compile", "Stop", "New", "Open", "Save", "Export"
|
||||
"Compile", "Stop", "New", "Open", "Save", "Export", "Serial Monitor"
|
||||
};
|
||||
|
||||
static final int BUTTON_COUNT = title.length;
|
||||
@ -52,6 +52,7 @@ public class EditorButtons extends JComponent implements MouseInputListener {
|
||||
static final int OPEN = 3;
|
||||
static final int SAVE = 4;
|
||||
static final int EXPORT = 5;
|
||||
static final int SERIAL = 6;
|
||||
|
||||
static final int INACTIVE = 0;
|
||||
static final int ROLLOVER = 1;
|
||||
@ -103,6 +104,7 @@ public class EditorButtons extends JComponent implements MouseInputListener {
|
||||
which[buttonCount++] = OPEN;
|
||||
which[buttonCount++] = SAVE;
|
||||
which[buttonCount++] = EXPORT;
|
||||
which[buttonCount++] = SERIAL;
|
||||
|
||||
currentRollover = -1;
|
||||
|
||||
@ -339,6 +341,7 @@ public class EditorButtons extends JComponent implements MouseInputListener {
|
||||
case NEW: editor.handleNew(e.isShiftDown()); break;
|
||||
case SAVE: editor.handleSave(); break;
|
||||
case EXPORT: editor.handleExport(); break;
|
||||
case SERIAL: editor.handleSerial(); break;
|
||||
}
|
||||
currentSelection = -1;
|
||||
}
|
||||
|
@ -59,59 +59,41 @@ public class Serial implements SerialPortEventListener {
|
||||
int bufferIndex;
|
||||
int bufferLast;
|
||||
|
||||
|
||||
// defaults
|
||||
|
||||
static String dname = Preferences.get("serial.port"); //"COM1";
|
||||
static int drate = 9600;
|
||||
static char dparity = 'N';
|
||||
static int ddatabits = 8;
|
||||
static float dstopbits = 1;
|
||||
|
||||
/*
|
||||
public void setProperties(Properties props) {
|
||||
dname =
|
||||
props.getProperty("serial.port", dname);
|
||||
drate =
|
||||
Integer.parseInt(props.getProperty("serial.rate", "9600"));
|
||||
dparity =
|
||||
props.getProperty("serial.parity", "N").charAt(0);
|
||||
ddatabits =
|
||||
Integer.parseInt(props.getProperty("serial.databits", "8"));
|
||||
dstopbits =
|
||||
new Float(props.getProperty("serial.stopbits", "1")).floatValue();
|
||||
}
|
||||
*/
|
||||
|
||||
public void setProperties() {
|
||||
//System.out.println("setting serial properties");
|
||||
dname = Preferences.get("serial.port");
|
||||
drate = Preferences.getInteger("serial.debug_rate");
|
||||
dparity = Preferences.get("serial.parity").charAt(0);
|
||||
ddatabits = Preferences.getInteger("serial.databits");
|
||||
dstopbits = new Float(Preferences.get("serial.stopbits")).floatValue();
|
||||
}
|
||||
|
||||
public Serial(boolean monitor) {
|
||||
this(dname, drate, dparity, ddatabits, dstopbits);
|
||||
this(Preferences.get("serial.port"),
|
||||
Preferences.getInteger("serial.debug_rate"),
|
||||
Preferences.get("serial.parity").charAt(0),
|
||||
Preferences.getInteger("serial.databits"),
|
||||
new Float(Preferences.get("serial.stopbits")).floatValue());
|
||||
this.monitor = monitor;
|
||||
}
|
||||
|
||||
public Serial() {
|
||||
//setProperties();
|
||||
this(dname, drate, dparity, ddatabits, dstopbits);
|
||||
this(Preferences.get("serial.port"),
|
||||
Preferences.getInteger("serial.debug_rate"),
|
||||
Preferences.get("serial.parity").charAt(0),
|
||||
Preferences.getInteger("serial.databits"),
|
||||
new Float(Preferences.get("serial.stopbits")).floatValue());
|
||||
}
|
||||
|
||||
public Serial(int irate) {
|
||||
this(dname, irate, dparity, ddatabits, dstopbits);
|
||||
this(Preferences.get("serial.port"), irate,
|
||||
Preferences.get("serial.parity").charAt(0),
|
||||
Preferences.getInteger("serial.databits"),
|
||||
new Float(Preferences.get("serial.stopbits")).floatValue());
|
||||
}
|
||||
|
||||
public Serial(String iname, int irate) {
|
||||
this(iname, irate, dparity, ddatabits, dstopbits);
|
||||
this(iname, irate, Preferences.get("serial.parity").charAt(0),
|
||||
Preferences.getInteger("serial.databits"),
|
||||
new Float(Preferences.get("serial.stopbits")).floatValue());
|
||||
}
|
||||
|
||||
public Serial(String iname) {
|
||||
this(iname, drate, dparity, ddatabits, dstopbits);
|
||||
this(iname, Preferences.getInteger("serial.debug_rate"),
|
||||
Preferences.get("serial.parity").charAt(0),
|
||||
Preferences.getInteger("serial.databits"),
|
||||
new Float(Preferences.get("serial.stopbits")).floatValue());
|
||||
}
|
||||
|
||||
public Serial(String iname, int irate,
|
||||
|
@ -20,7 +20,7 @@
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
$Id:$
|
||||
$Id$
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
@ -21,7 +21,7 @@
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
$Id:$
|
||||
$Id$
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
@ -21,7 +21,7 @@
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
$Id:$
|
||||
$Id$
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
|
@ -4,7 +4,7 @@ package antlr;
|
||||
* Project led by Terence Parr at http://www.jGuru.com
|
||||
* Software rights: http://www.antlr.org/RIGHTS.html
|
||||
*
|
||||
* $Id: ExtendedCommonASTWithHiddenTokens.java,v 1.1.1.1 2005/06/22 22:18:14 h Exp $
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
|
@ -15,7 +15,7 @@ import javax.swing.text.Segment;
|
||||
* C token marker.
|
||||
*
|
||||
* @author Slava Pestov
|
||||
* @version $Id: CTokenMarker.java,v 1.1 2005/04/09 02:30:37 benfry Exp $
|
||||
* @version $Id$
|
||||
*/
|
||||
public class CTokenMarker extends TokenMarker
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ import java.util.StringTokenizer;
|
||||
* The default input handler. It maps sequences of keystrokes into actions
|
||||
* and inserts key typed events into the text area.
|
||||
* @author Slava Pestov
|
||||
* @version $Id: DefaultInputHandler.java,v 1.2 2005/05/11 08:34:16 benfry Exp $
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DefaultInputHandler extends InputHandler
|
||||
{
|
||||
|
@ -24,7 +24,7 @@ import java.util.*;
|
||||
* to the implementations of this class to do so.
|
||||
*
|
||||
* @author Slava Pestov
|
||||
* @version $Id: InputHandler.java,v 1.1 2005/04/09 02:30:37 benfry Exp $
|
||||
* @version $Id$
|
||||
* @see org.gjt.sp.jedit.textarea.DefaultInputHandler
|
||||
*/
|
||||
public abstract class InputHandler extends KeyAdapter
|
||||
|
@ -52,7 +52,7 @@ import java.util.Vector;
|
||||
* + "}");</pre>
|
||||
*
|
||||
* @author Slava Pestov
|
||||
* @version $Id: JEditTextArea.java,v 1.5 2005/05/10 00:29:05 benfry Exp $
|
||||
* @version $Id$
|
||||
*/
|
||||
public class JEditTextArea extends JComponent
|
||||
{
|
||||
|
@ -20,7 +20,7 @@ import javax.swing.text.Segment;
|
||||
* This class is used by <code>CTokenMarker</code> to map keywords to ids.
|
||||
*
|
||||
* @author Slava Pestov, Mike Dillon
|
||||
* @version $Id: KeywordMap.java,v 1.1 2005/04/09 02:30:37 benfry Exp $
|
||||
* @version $Id$
|
||||
*/
|
||||
public class KeywordMap
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ import javax.swing.undo.UndoableEdit;
|
||||
* system.
|
||||
*
|
||||
* @author Slava Pestov
|
||||
* @version $Id: SyntaxDocument.java,v 1.1 2005/04/09 02:30:37 benfry Exp $
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SyntaxDocument extends PlainDocument
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ import java.util.StringTokenizer;
|
||||
* A simple text style class. It can specify the color, italic flag,
|
||||
* and bold flag of a run of text.
|
||||
* @author Slava Pestov
|
||||
* @version $Id: SyntaxStyle.java,v 1.1 2005/04/09 02:30:37 benfry Exp $
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SyntaxStyle
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ import java.awt.*;
|
||||
* subsystem.
|
||||
*
|
||||
* @author Slava Pestov
|
||||
* @version $Id: SyntaxUtilities.java,v 1.1 2005/04/09 02:30:37 benfry Exp $
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SyntaxUtilities
|
||||
{
|
||||
|
@ -23,7 +23,7 @@ import java.awt.*;
|
||||
* The text area repaint manager. It performs double buffering and paints
|
||||
* lines of text.
|
||||
* @author Slava Pestov
|
||||
* @version $Id: TextAreaPainter.java,v 1.3 2005/05/10 01:17:21 benfry Exp $
|
||||
* @version $Id$
|
||||
*/
|
||||
public class TextAreaPainter extends JComponent implements TabExpander
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ import javax.swing.text.*;
|
||||
/**
|
||||
* Class with several utility functions used by the text area component.
|
||||
* @author Slava Pestov
|
||||
* @version $Id: TextUtilities.java,v 1.1 2005/04/09 02:30:37 benfry Exp $
|
||||
* @version $Id$
|
||||
*/
|
||||
public class TextUtilities
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ package processing.app.syntax;
|
||||
* token in the text, and a pointer to the next token in the list.
|
||||
*
|
||||
* @author Slava Pestov
|
||||
* @version $Id: Token.java,v 1.1 2005/04/09 02:30:37 benfry Exp $
|
||||
* @version $Id$
|
||||
*/
|
||||
public class Token
|
||||
{
|
||||
|
@ -23,7 +23,7 @@ import java.util.*;
|
||||
* cached.
|
||||
*
|
||||
* @author Slava Pestov
|
||||
* @version $Id: TokenMarker.java,v 1.1 2005/04/09 02:30:37 benfry Exp $
|
||||
* @version $Id$
|
||||
*
|
||||
* @see org.gjt.sp.jedit.syntax.Token
|
||||
*/
|
||||
|
Reference in New Issue
Block a user