1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-22 08:22:04 +03:00

Merge branch 'ide-1.5.x' into dev-ide-1.5.x-discovery

Conflicts:
	app/src/processing/app/Preferences.java
	app/src/processing/app/debug/Uploader.java
This commit is contained in:
Cristian Maglie
2013-08-23 15:59:24 +02:00
840 changed files with 170908 additions and 18320 deletions

View File

@ -31,6 +31,7 @@ import processing.app.Preferences;
import processing.app.debug.MessageConsumer;
import processing.app.debug.MessageSiphon;
import processing.app.debug.RunnerException;
import processing.app.helpers.ProcessUtils;
import processing.app.helpers.StringUtils;
import java.io.File;
@ -98,7 +99,7 @@ public abstract class Uploader implements MessageConsumer {
System.out.print(c + " ");
System.out.println();
}
Process process = Runtime.getRuntime().exec(command);
Process process = ProcessUtils.exec(command);
new MessageSiphon(process.getInputStream(), this);
new MessageSiphon(process.getErrorStream(), this);

View File

@ -33,7 +33,6 @@ import processing.app.*;
import processing.app.debug.RunnerException;
import processing.app.debug.TargetPlatform;
import processing.app.helpers.PreferencesMap;
import processing.app.helpers.PreferencesMapException;
import processing.app.helpers.StringReplacer;
import java.io.File;

View File

@ -145,7 +145,7 @@ public class Base {
File versionFile = getContentFile("lib/version.txt");
if (versionFile.exists()) {
String version = PApplet.loadStrings(versionFile)[0];
if (!version.equals(VERSION_NAME)) {
if (!version.equals(VERSION_NAME) && !version.equals("${version}")) {
VERSION_NAME = version;
RELEASE = true;
}
@ -154,6 +154,10 @@ public class Base {
e.printStackTrace();
}
// help 3rd party installers find the correct hardware path
Preferences.set("last.ide." + VERSION_NAME + ".hardwarepath", getHardwarePath());
Preferences.set("last.ide." + VERSION_NAME + ".daterun", "" + (new Date()).getTime() / 1000);
// if (System.getProperty("mrj.version") != null) {
// //String jv = System.getProperty("java.version");
// String ov = System.getProperty("os.version");

View File

@ -650,6 +650,7 @@ public class Editor extends JFrame implements RunnerListener {
if (importMenu == null) {
importMenu = new JMenu(_("Import Library..."));
MenuScroller.setScrollerFor(importMenu);
base.rebuildImportMenu(importMenu, this);
}
sketchMenu.add(importMenu);

View File

@ -452,25 +452,21 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
add(progressBar);
progressBar.setVisible(false);
copyErrorButton = new JButton(
"<html>" + _("Copy error") + "<br>" + _("to clipboard") + "</html>");
Font font = copyErrorButton.getFont();
font = new Font(font.getName(), font.getStyle(), (int) (font.getSize()*0.7));
copyErrorButton.setFont(font);
copyErrorButton.setHorizontalAlignment(JLabel.CENTER);
copyErrorButton = new JButton(_("Copy error"));
add(copyErrorButton);
copyErrorButton.setVisible(false);
copyErrorButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String message="";
String message = "";
message += _("Arduino: ") + Base.VERSION_NAME + " (" + System.getProperty("os.name") + "), ";
message += _("Board: ") + "\"" + Base.getBoardPreferences().get("name") + "\"\n\n";
message += editor.console.consoleTextPane.getText().trim();
if ((Preferences.getBoolean("build.verbose")) == false) {
message = " " + _("This report would have more information with") + "\n";
message += "\n\n";
message += " " + _("This report would have more information with") + "\n";
message += " \"" + _("Show verbose output during compilation") + "\"\n";
message += " " + _("enabled in File > Preferences.") + "\n";
}
message += _("Arduino: ") + Base.VERSION_NAME + " (" + System.getProperty("os.name") + "), ";
message += _("Board: ") + "\"" + Base.getBoardPreferences().get("name") + "\"\n";
message += editor.console.consoleTextPane.getText().trim();
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection data = new StringSelection(message);
clipboard.setContents(data, null);

View File

@ -218,7 +218,7 @@ public class Preferences {
// data model
static Hashtable defaults;
static Hashtable table = new Hashtable();
static Hashtable<String, String> table = new Hashtable<String, String>();
static File preferencesFile;
@ -242,9 +242,8 @@ public class Preferences {
// check for platform-specific properties in the defaults
String platformExt = "." + Base.platform.getName();
int platformExtLength = platformExt.length();
Enumeration e = table.keys();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
Set<String> keySet = new HashSet<String>(table.keySet());
for (String key : keySet) {
if (key.endsWith(platformExt)) {
// this is a key specific to a particular platform
String actualKey = key.substring(0, key.length() - platformExtLength);
@ -791,12 +790,12 @@ public class Preferences {
// Fix for 0163 to properly use Unicode when writing preferences.txt
PrintWriter writer = PApplet.createWriter(preferencesFile);
String[] keys = (String[])table.keySet().toArray(new String[0]);
String[] keys = table.keySet().toArray(new String[0]);
Arrays.sort(keys);
for (String key: keys) {
if (key.startsWith("runtime."))
continue;
writer.println(key + "=" + ((String) table.get(key)));
writer.println(key + "=" + table.get(key));
}
writer.flush();
@ -818,7 +817,7 @@ public class Preferences {
//}
static public String get(String attribute /*, String defaultValue */) {
return (String) table.get(attribute);
return table.get(attribute);
/*
//String value = (properties != null) ?
//properties.getProperty(attribute) : applet.getParameter(attribute);

View File

@ -39,6 +39,7 @@ import processing.app.Preferences;
import processing.app.Sketch;
import processing.app.SketchCode;
import processing.app.helpers.PreferencesMap;
import processing.app.helpers.ProcessUtils;
import processing.app.helpers.StringReplacer;
import processing.app.helpers.filefilters.OnlyDirs;
import processing.app.packages.Library;
@ -343,9 +344,8 @@ public class Compiler implements MessageConsumer {
secondErrorFound = false;
Process process;
try {
process = Runtime.getRuntime().exec(command);
process = ProcessUtils.exec(command);
} catch (IOException e) {
RunnerException re = new RunnerException(e.getMessage());
re.hideStackTrace();

View File

@ -30,6 +30,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import processing.app.helpers.PreferencesMap;
import processing.app.helpers.ProcessUtils;
import processing.app.helpers.StringReplacer;
public class Sizer implements MessageConsumer {
@ -67,7 +68,7 @@ public class Sizer implements MessageConsumer {
textSize = -1;
dataSize = -1;
eepromSize = -1;
Process process = Runtime.getRuntime().exec(cmd);
Process process = ProcessUtils.exec(cmd);
MessageSiphon in = new MessageSiphon(process.getInputStream(), this);
MessageSiphon err = new MessageSiphon(process.getErrorStream(), this);

View File

@ -0,0 +1,25 @@
package processing.app.helpers;
import java.io.IOException;
import processing.app.Base;
public class ProcessUtils {
public static Process exec(String[] command) throws IOException {
// No problems on linux and mac
if (!Base.isWindows()) {
return Runtime.getRuntime().exec(command);
}
// Brutal hack to workaround windows command line parsing.
// http://stackoverflow.com/questions/5969724/java-runtime-exec-fails-to-escape-characters-properly
// http://msdn.microsoft.com/en-us/library/a1y7w461.aspx
// http://bugs.sun.com/view_bug.do?bug_id=6468220
// http://bugs.sun.com/view_bug.do?bug_id=6518827
String[] cmdLine = new String[command.length];
for (int i = 0; i < command.length; i++)
cmdLine[i] = command[i].replace("\"", "\\\"");
return Runtime.getRuntime().exec(cmdLine);
}
}

View File

@ -108,9 +108,9 @@ public class Platform extends processing.app.Platform {
public void openFolder(File file) throws Exception {
if (openFolderAvailable()) {
String lunch = Preferences.get("launcher");
String launcher = Preferences.get("launcher");
try {
String[] params = new String[] { lunch, file.getAbsolutePath() };
String[] params = new String[] { launcher, file.getAbsolutePath() };
//processing.core.PApplet.println(params);
/*Process p =*/ Runtime.getRuntime().exec(params);
/*int result =*/ //p.waitFor();

View File

@ -3,12 +3,16 @@
*/
package processing.app.tools;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JMenu;
@ -20,7 +24,7 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import javax.swing.plaf.*;
import javax.swing.plaf.ButtonUI;
/**
* A class that provides scrolling capabilities to a long menu dropdown or
@ -42,6 +46,7 @@ public class MenuScroller {
private MenuScrollItem upItem;
private MenuScrollItem downItem;
private final MenuScrollListener menuListener = new MenuScrollListener();
private final MouseScrollListener mouseWheelListener = new MouseScrollListener();
private int scrollCount;
private int interval;
private int topFixedCount;
@ -320,6 +325,7 @@ public class MenuScroller {
this.menu = menu;
menu.addPopupMenuListener(menuListener);
menu.addMouseWheelListener(mouseWheelListener);
}
/**
@ -446,6 +452,7 @@ public class MenuScroller {
public void dispose() {
if (menu != null) {
menu.removePopupMenuListener(menuListener);
menu.removeMouseWheelListener(mouseWheelListener);
menu = null;
}
}
@ -497,6 +504,14 @@ public class MenuScroller {
}
}
private class MouseScrollListener implements MouseWheelListener {
public void mouseWheelMoved(MouseWheelEvent mwe) {
firstIndex += mwe.getWheelRotation();
refreshMenu();
mwe.consume();
}
}
private class MenuScrollListener implements PopupMenuListener {
@Override
@ -555,6 +570,7 @@ public class MenuScroller {
}
}
@SuppressWarnings("serial")
private class MenuScrollTimer extends Timer {
public MenuScrollTimer(final int increment, int interval) {
@ -569,6 +585,7 @@ public class MenuScroller {
}
}
@SuppressWarnings("serial")
private class MenuScrollItem extends JMenuItem
implements ChangeListener {