mirror of https://github.com/noisymime/Arduino.git
Refactored OS detection subroutine.
Moved from Base into a specific utility class OSUtils. Removed unused platform constants.
This commit is contained in:
parent
e0f680be5b
commit
50f89d9665
|
@ -39,6 +39,7 @@ import processing.app.Serial;
|
||||||
import processing.app.SerialException;
|
import processing.app.SerialException;
|
||||||
import processing.app.debug.RunnerException;
|
import processing.app.debug.RunnerException;
|
||||||
import processing.app.debug.TargetPlatform;
|
import processing.app.debug.TargetPlatform;
|
||||||
|
import processing.app.helpers.OSUtils;
|
||||||
import processing.app.helpers.PreferencesMap;
|
import processing.app.helpers.PreferencesMap;
|
||||||
import processing.app.helpers.StringReplacer;
|
import processing.app.helpers.StringReplacer;
|
||||||
import cc.arduino.packages.Uploader;
|
import cc.arduino.packages.Uploader;
|
||||||
|
@ -188,7 +189,7 @@ public class SerialUploader extends Uploader {
|
||||||
// come back, so use a longer time out before assuming that the
|
// come back, so use a longer time out before assuming that the
|
||||||
// selected
|
// selected
|
||||||
// port is the bootloader (not the sketch).
|
// port is the bootloader (not the sketch).
|
||||||
if (((!Base.isWindows() && elapsed >= 500) || elapsed >= 5000) && now.contains(uploadPort)) {
|
if (((!OSUtils.isWindows() && elapsed >= 500) || elapsed >= 5000) && now.contains(uploadPort)) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
System.out.println("Uploading using selected port: " + uploadPort);
|
System.out.println("Uploading using selected port: " + uploadPort);
|
||||||
return uploadPort;
|
return uploadPort;
|
||||||
|
|
|
@ -42,12 +42,12 @@ import processing.app.debug.TargetPackage;
|
||||||
import processing.app.debug.TargetPlatform;
|
import processing.app.debug.TargetPlatform;
|
||||||
import processing.app.debug.TargetPlatformException;
|
import processing.app.debug.TargetPlatformException;
|
||||||
import processing.app.helpers.FileUtils;
|
import processing.app.helpers.FileUtils;
|
||||||
|
import processing.app.helpers.OSUtils;
|
||||||
import processing.app.helpers.PreferencesMap;
|
import processing.app.helpers.PreferencesMap;
|
||||||
import processing.app.helpers.filefilters.OnlyDirs;
|
import processing.app.helpers.filefilters.OnlyDirs;
|
||||||
import processing.app.helpers.filefilters.OnlyFilesWithExtension;
|
import processing.app.helpers.filefilters.OnlyFilesWithExtension;
|
||||||
import processing.app.javax.swing.filechooser.FileNameExtensionFilter;
|
import processing.app.javax.swing.filechooser.FileNameExtensionFilter;
|
||||||
import processing.app.legacy.PApplet;
|
import processing.app.legacy.PApplet;
|
||||||
import processing.app.legacy.PConstants;
|
|
||||||
import processing.app.packages.Library;
|
import processing.app.packages.Library;
|
||||||
import processing.app.packages.LibraryList;
|
import processing.app.packages.LibraryList;
|
||||||
import processing.app.tools.MenuScroller;
|
import processing.app.tools.MenuScroller;
|
||||||
|
@ -68,19 +68,6 @@ public class Base {
|
||||||
/** Set true if this a proper release rather than a numbered revision. */
|
/** Set true if this a proper release rather than a numbered revision. */
|
||||||
static public boolean RELEASE = false;
|
static public boolean RELEASE = false;
|
||||||
|
|
||||||
static Map<Integer, String> platformNames = new HashMap<Integer, String>();
|
|
||||||
static {
|
|
||||||
platformNames.put(PConstants.WINDOWS, "windows");
|
|
||||||
platformNames.put(PConstants.MACOSX, "macosx");
|
|
||||||
platformNames.put(PConstants.LINUX, "linux");
|
|
||||||
}
|
|
||||||
|
|
||||||
static HashMap<String, Integer> platformIndices = new HashMap<String, Integer>();
|
|
||||||
static {
|
|
||||||
platformIndices.put("windows", PConstants.WINDOWS);
|
|
||||||
platformIndices.put("macosx", PConstants.MACOSX);
|
|
||||||
platformIndices.put("linux", PConstants.LINUX);
|
|
||||||
}
|
|
||||||
static Platform platform;
|
static Platform platform;
|
||||||
|
|
||||||
private static DiscoveryManager discoveryManager = new DiscoveryManager();
|
private static DiscoveryManager discoveryManager = new DiscoveryManager();
|
||||||
|
@ -263,11 +250,11 @@ public class Base {
|
||||||
static protected void initPlatform() {
|
static protected void initPlatform() {
|
||||||
try {
|
try {
|
||||||
Class<?> platformClass = Class.forName("processing.app.Platform");
|
Class<?> platformClass = Class.forName("processing.app.Platform");
|
||||||
if (Base.isMacOS()) {
|
if (OSUtils.isMacOS()) {
|
||||||
platformClass = Class.forName("processing.app.macosx.Platform");
|
platformClass = Class.forName("processing.app.macosx.Platform");
|
||||||
} else if (Base.isWindows()) {
|
} else if (OSUtils.isWindows()) {
|
||||||
platformClass = Class.forName("processing.app.windows.Platform");
|
platformClass = Class.forName("processing.app.windows.Platform");
|
||||||
} else if (Base.isLinux()) {
|
} else if (OSUtils.isLinux()) {
|
||||||
platformClass = Class.forName("processing.app.linux.Platform");
|
platformClass = Class.forName("processing.app.linux.Platform");
|
||||||
}
|
}
|
||||||
platform = (Platform) platformClass.newInstance();
|
platform = (Platform) platformClass.newInstance();
|
||||||
|
@ -473,7 +460,7 @@ public class Base {
|
||||||
// being passed in with 8.3 syntax, which makes the sketch loader code
|
// being passed in with 8.3 syntax, which makes the sketch loader code
|
||||||
// unhappy, since the sketch folder naming doesn't match up correctly.
|
// unhappy, since the sketch folder naming doesn't match up correctly.
|
||||||
// http://dev.processing.org/bugs/show_bug.cgi?id=1089
|
// http://dev.processing.org/bugs/show_bug.cgi?id=1089
|
||||||
if (isWindows()) {
|
if (OSUtils.isWindows()) {
|
||||||
try {
|
try {
|
||||||
file = file.getCanonicalFile();
|
file = file.getCanonicalFile();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -1087,7 +1074,7 @@ public class Base {
|
||||||
// untitled sketch, just give up and let the user quit.
|
// untitled sketch, just give up and let the user quit.
|
||||||
// if (Preferences.getBoolean("sketchbook.closing_last_window_quits") ||
|
// if (Preferences.getBoolean("sketchbook.closing_last_window_quits") ||
|
||||||
// (editor.untitled && !editor.getSketch().isModified())) {
|
// (editor.untitled && !editor.getSketch().isModified())) {
|
||||||
if (Base.isMacOS()) {
|
if (OSUtils.isMacOS()) {
|
||||||
Object[] options = { "OK", "Cancel" };
|
Object[] options = { "OK", "Cancel" };
|
||||||
String prompt =
|
String prompt =
|
||||||
_("<html> " +
|
_("<html> " +
|
||||||
|
@ -1170,7 +1157,7 @@ public class Base {
|
||||||
// Save out the current prefs state
|
// Save out the current prefs state
|
||||||
Preferences.save();
|
Preferences.save();
|
||||||
|
|
||||||
if (!Base.isMacOS()) {
|
if (!OSUtils.isMacOS()) {
|
||||||
// If this was fired from the menu or an AppleEvent (the Finder),
|
// If this was fired from the menu or an AppleEvent (the Finder),
|
||||||
// then Mac OS X will send the terminate signal itself.
|
// then Mac OS X will send the terminate signal itself.
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
|
@ -1996,54 +1983,6 @@ public class Base {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Map a platform constant to its name.
|
|
||||||
* @param which PConstants.WINDOWS, PConstants.MACOSX, PConstants.LINUX
|
|
||||||
* @return one of "windows", "macosx", or "linux"
|
|
||||||
*/
|
|
||||||
static public String getPlatformName(int which) {
|
|
||||||
return platformNames.get(which);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static public int getPlatformIndex(String what) {
|
|
||||||
Integer entry = platformIndices.get(what);
|
|
||||||
return (entry == null) ? -1 : entry.intValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// These were changed to no longer rely on PApplet and PConstants because
|
|
||||||
// of conflicts that could happen with older versions of core.jar, where
|
|
||||||
// the MACOSX constant would instead read as the LINUX constant.
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* returns true if Processing is running on a Mac OS X machine.
|
|
||||||
*/
|
|
||||||
static public boolean isMacOS() {
|
|
||||||
//return PApplet.platform == PConstants.MACOSX;
|
|
||||||
return System.getProperty("os.name").indexOf("Mac") != -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* returns true if running on windows.
|
|
||||||
*/
|
|
||||||
static public boolean isWindows() {
|
|
||||||
//return PApplet.platform == PConstants.WINDOWS;
|
|
||||||
return System.getProperty("os.name").indexOf("Windows") != -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* true if running on linux.
|
|
||||||
*/
|
|
||||||
static public boolean isLinux() {
|
|
||||||
//return PApplet.platform == PConstants.LINUX;
|
|
||||||
return System.getProperty("os.name").indexOf("Linux") != -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// .................................................................
|
// .................................................................
|
||||||
|
|
||||||
|
|
||||||
|
@ -2176,7 +2115,7 @@ public class Base {
|
||||||
static public String getAvrBasePath() {
|
static public String getAvrBasePath() {
|
||||||
String path = getHardwarePath() + File.separator + "tools" +
|
String path = getHardwarePath() + File.separator + "tools" +
|
||||||
File.separator + "avr" + File.separator + "bin" + File.separator;
|
File.separator + "avr" + File.separator + "bin" + File.separator;
|
||||||
if (Base.isLinux() && !(new File(path)).exists()) {
|
if (OSUtils.isLinux() && !(new File(path)).exists()) {
|
||||||
return ""; // use distribution provided avr tools if bundled tools missing
|
return ""; // use distribution provided avr tools if bundled tools missing
|
||||||
}
|
}
|
||||||
return path;
|
return path;
|
||||||
|
@ -2411,7 +2350,7 @@ public class Base {
|
||||||
static public void setIcon(Frame frame) {
|
static public void setIcon(Frame frame) {
|
||||||
// don't use the low-res icon on Mac OS X; the window should
|
// don't use the low-res icon on Mac OS X; the window should
|
||||||
// already have the right icon from the .app file.
|
// already have the right icon from the .app file.
|
||||||
if (Base.isMacOS()) return;
|
if (OSUtils.isMacOS()) return;
|
||||||
|
|
||||||
Image image = Toolkit.getDefaultToolkit().createImage(PApplet.ICON_IMAGE);
|
Image image = Toolkit.getDefaultToolkit().createImage(PApplet.ICON_IMAGE);
|
||||||
frame.setIconImage(image);
|
frame.setIconImage(image);
|
||||||
|
@ -2464,9 +2403,9 @@ public class Base {
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void showGettingStarted() {
|
static public void showGettingStarted() {
|
||||||
if (Base.isMacOS()) {
|
if (OSUtils.isMacOS()) {
|
||||||
Base.showReference(_("Guide_MacOSX.html"));
|
Base.showReference(_("Guide_MacOSX.html"));
|
||||||
} else if (Base.isWindows()) {
|
} else if (OSUtils.isWindows()) {
|
||||||
Base.showReference(_("Guide_Windows.html"));
|
Base.showReference(_("Guide_Windows.html"));
|
||||||
} else {
|
} else {
|
||||||
Base.openURL(_("http://www.arduino.cc/playground/Learning/Linux"));
|
Base.openURL(_("http://www.arduino.cc/playground/Learning/Linux"));
|
||||||
|
@ -2570,7 +2509,7 @@ public class Base {
|
||||||
// incomplete
|
// incomplete
|
||||||
static public int showYesNoCancelQuestion(Editor editor, String title,
|
static public int showYesNoCancelQuestion(Editor editor, String title,
|
||||||
String primary, String secondary) {
|
String primary, String secondary) {
|
||||||
if (!Base.isMacOS()) {
|
if (!OSUtils.isMacOS()) {
|
||||||
int result =
|
int result =
|
||||||
JOptionPane.showConfirmDialog(null, primary + "\n" + secondary, title,
|
JOptionPane.showConfirmDialog(null, primary + "\n" + secondary, title,
|
||||||
JOptionPane.YES_NO_CANCEL_OPTION,
|
JOptionPane.YES_NO_CANCEL_OPTION,
|
||||||
|
@ -2646,7 +2585,7 @@ public class Base {
|
||||||
|
|
||||||
static public int showYesNoQuestion(Frame editor, String title,
|
static public int showYesNoQuestion(Frame editor, String title,
|
||||||
String primary, String secondary) {
|
String primary, String secondary) {
|
||||||
if (!Base.isMacOS()) {
|
if (!OSUtils.isMacOS()) {
|
||||||
return JOptionPane.showConfirmDialog(editor,
|
return JOptionPane.showConfirmDialog(editor,
|
||||||
"<html><body>" +
|
"<html><body>" +
|
||||||
"<b>" + primary + "</b>" +
|
"<b>" + primary + "</b>" +
|
||||||
|
@ -2730,7 +2669,7 @@ public class Base {
|
||||||
String path = System.getProperty("user.dir");
|
String path = System.getProperty("user.dir");
|
||||||
|
|
||||||
// Get a path to somewhere inside the .app folder
|
// Get a path to somewhere inside the .app folder
|
||||||
if (Base.isMacOS()) {
|
if (OSUtils.isMacOS()) {
|
||||||
// <key>javaroot</key>
|
// <key>javaroot</key>
|
||||||
// <string>$JAVAROOT</string>
|
// <string>$JAVAROOT</string>
|
||||||
String javaroot = System.getProperty("javaroot");
|
String javaroot = System.getProperty("javaroot");
|
||||||
|
|
|
@ -28,6 +28,7 @@ import com.jcraft.jsch.JSchException;
|
||||||
|
|
||||||
import processing.app.debug.*;
|
import processing.app.debug.*;
|
||||||
import processing.app.forms.PasswordAuthorizationDialog;
|
import processing.app.forms.PasswordAuthorizationDialog;
|
||||||
|
import processing.app.helpers.OSUtils;
|
||||||
import processing.app.helpers.PreferencesMapException;
|
import processing.app.helpers.PreferencesMapException;
|
||||||
import processing.app.legacy.PApplet;
|
import processing.app.legacy.PApplet;
|
||||||
import processing.app.syntax.*;
|
import processing.app.syntax.*;
|
||||||
|
@ -591,7 +592,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||||
fileMenu.add(item);
|
fileMenu.add(item);
|
||||||
|
|
||||||
// macosx already has its own preferences and quit menu
|
// macosx already has its own preferences and quit menu
|
||||||
if (!Base.isMacOS()) {
|
if (!OSUtils.isMacOS()) {
|
||||||
fileMenu.addSeparator();
|
fileMenu.addSeparator();
|
||||||
|
|
||||||
item = newJMenuItem(_("Preferences"), ',');
|
item = newJMenuItem(_("Preferences"), ',');
|
||||||
|
@ -1110,7 +1111,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||||
menu.add(item);
|
menu.add(item);
|
||||||
|
|
||||||
// macosx already has its own about menu
|
// macosx already has its own about menu
|
||||||
if (!Base.isMacOS()) {
|
if (!OSUtils.isMacOS()) {
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
item = new JMenuItem(_("About Arduino"));
|
item = new JMenuItem(_("About Arduino"));
|
||||||
item.addActionListener(new ActionListener() {
|
item.addActionListener(new ActionListener() {
|
||||||
|
@ -1135,7 +1136,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||||
undoItem.addActionListener(undoAction = new UndoAction());
|
undoItem.addActionListener(undoAction = new UndoAction());
|
||||||
menu.add(undoItem);
|
menu.add(undoItem);
|
||||||
|
|
||||||
if (!Base.isMacOS()) {
|
if (!OSUtils.isMacOS()) {
|
||||||
redoItem = newJMenuItem(_("Redo"), 'Y');
|
redoItem = newJMenuItem(_("Redo"), 'Y');
|
||||||
} else {
|
} else {
|
||||||
redoItem = newJMenuItemShift(_("Redo"), 'Z');
|
redoItem = newJMenuItemShift(_("Redo"), 'Z');
|
||||||
|
@ -2031,7 +2032,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||||
|
|
||||||
String prompt = I18n.format(_("Save changes to \"{0}\"? "), sketch.getName());
|
String prompt = I18n.format(_("Save changes to \"{0}\"? "), sketch.getName());
|
||||||
|
|
||||||
if (!Base.isMacOS()) {
|
if (!OSUtils.isMacOS()) {
|
||||||
int result =
|
int result =
|
||||||
JOptionPane.showConfirmDialog(this, prompt, _("Close"),
|
JOptionPane.showConfirmDialog(this, prompt, _("Close"),
|
||||||
JOptionPane.YES_NO_CANCEL_OPTION,
|
JOptionPane.YES_NO_CANCEL_OPTION,
|
||||||
|
|
|
@ -40,6 +40,8 @@ import javax.swing.text.Element;
|
||||||
import javax.swing.text.SimpleAttributeSet;
|
import javax.swing.text.SimpleAttributeSet;
|
||||||
import javax.swing.text.StyleConstants;
|
import javax.swing.text.StyleConstants;
|
||||||
|
|
||||||
|
import processing.app.helpers.OSUtils;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Message console that sits below the editing area.
|
* Message console that sits below the editing area.
|
||||||
|
@ -118,7 +120,7 @@ public class EditorConsole extends JScrollPane {
|
||||||
|
|
||||||
// to fix ugliness.. normally macosx java 1.3 puts an
|
// to fix ugliness.. normally macosx java 1.3 puts an
|
||||||
// ugly white border around this object, so turn it off.
|
// ugly white border around this object, so turn it off.
|
||||||
if (Base.isMacOS()) {
|
if (OSUtils.isMacOS()) {
|
||||||
setBorder(null);
|
setBorder(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package processing.app;
|
package processing.app;
|
||||||
|
import processing.app.helpers.OSUtils;
|
||||||
import processing.app.tools.MenuScroller;
|
import processing.app.tools.MenuScroller;
|
||||||
import static processing.app.I18n._;
|
import static processing.app.I18n._;
|
||||||
|
|
||||||
|
@ -381,7 +382,7 @@ public class EditorHeader extends JComponent {
|
||||||
|
|
||||||
|
|
||||||
public Dimension getMinimumSize() {
|
public Dimension getMinimumSize() {
|
||||||
if (Base.isMacOS()) {
|
if (OSUtils.isMacOS()) {
|
||||||
return new Dimension(300, Preferences.GRID_SIZE);
|
return new Dimension(300, Preferences.GRID_SIZE);
|
||||||
}
|
}
|
||||||
return new Dimension(300, Preferences.GRID_SIZE - 1);
|
return new Dimension(300, Preferences.GRID_SIZE - 1);
|
||||||
|
@ -389,7 +390,7 @@ public class EditorHeader extends JComponent {
|
||||||
|
|
||||||
|
|
||||||
public Dimension getMaximumSize() {
|
public Dimension getMaximumSize() {
|
||||||
if (Base.isMacOS()) {
|
if (OSUtils.isMacOS()) {
|
||||||
return new Dimension(3000, Preferences.GRID_SIZE);
|
return new Dimension(3000, Preferences.GRID_SIZE);
|
||||||
}
|
}
|
||||||
return new Dimension(3000, Preferences.GRID_SIZE - 1);
|
return new Dimension(3000, Preferences.GRID_SIZE - 1);
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
package processing.app;
|
package processing.app;
|
||||||
|
|
||||||
|
import processing.app.helpers.OSUtils;
|
||||||
import processing.app.syntax.*;
|
import processing.app.syntax.*;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
@ -61,7 +62,7 @@ public class EditorLineStatus extends JComponent {
|
||||||
foreground = Theme.getColor("linestatus.color");
|
foreground = Theme.getColor("linestatus.color");
|
||||||
high = Theme.getInteger("linestatus.height");
|
high = Theme.getInteger("linestatus.height");
|
||||||
|
|
||||||
if (Base.isMacOS()) {
|
if (OSUtils.isMacOS()) {
|
||||||
resize = Base.getThemeImage("resize.gif", this);
|
resize = Base.getThemeImage("resize.gif", this);
|
||||||
}
|
}
|
||||||
//linestatus.bgcolor = #000000
|
//linestatus.bgcolor = #000000
|
||||||
|
@ -118,7 +119,7 @@ public class EditorLineStatus extends JComponent {
|
||||||
|
|
||||||
g.drawString(tmp, size.width - (int) bounds.getWidth() -20 , baseline);
|
g.drawString(tmp, size.width - (int) bounds.getWidth() -20 , baseline);
|
||||||
|
|
||||||
if (Base.isMacOS()) {
|
if (OSUtils.isMacOS()) {
|
||||||
g.drawImage(resize, size.width - 20, 0, this);
|
g.drawImage(resize, size.width - 20, 0, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,13 @@ package processing.app;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
|
import processing.app.helpers.OSUtils;
|
||||||
|
|
||||||
import java.awt.datatransfer.*;
|
import java.awt.datatransfer.*;
|
||||||
|
|
||||||
import static processing.app.I18n._;
|
import static processing.app.I18n._;
|
||||||
|
|
||||||
|
|
||||||
|
@ -331,7 +335,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
|
||||||
|
|
||||||
// !@#(* aqua ui #($*(( that turtle-neck wearing #(** (#$@)(
|
// !@#(* aqua ui #($*(( that turtle-neck wearing #(** (#$@)(
|
||||||
// os9 seems to work if bg of component is set, but x still a bastard
|
// os9 seems to work if bg of component is set, but x still a bastard
|
||||||
if (Base.isMacOS()) {
|
if (OSUtils.isMacOS()) {
|
||||||
//yesButton.setBackground(bgcolor[EDIT]);
|
//yesButton.setBackground(bgcolor[EDIT]);
|
||||||
//noButton.setBackground(bgcolor[EDIT]);
|
//noButton.setBackground(bgcolor[EDIT]);
|
||||||
cancelButton.setBackground(bgcolor[EDIT]);
|
cancelButton.setBackground(bgcolor[EDIT]);
|
||||||
|
@ -444,7 +448,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
|
||||||
|
|
||||||
progressBar = new JProgressBar(JScrollBar.HORIZONTAL);
|
progressBar = new JProgressBar(JScrollBar.HORIZONTAL);
|
||||||
progressBar.setIndeterminate(false);
|
progressBar.setIndeterminate(false);
|
||||||
if (Base.isMacOS()) {
|
if (OSUtils.isMacOS()) {
|
||||||
//progressBar.setBackground(bgcolor[PROGRESS]);
|
//progressBar.setBackground(bgcolor[PROGRESS]);
|
||||||
//progressBar.putClientProperty("JProgressBar.style", "circular");
|
//progressBar.putClientProperty("JProgressBar.style", "circular");
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,11 @@ import static processing.app.I18n._;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
|
import processing.app.helpers.OSUtils;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find & Replace window for the Processing editor.
|
* Find & Replace window for the Processing editor.
|
||||||
|
@ -47,7 +50,7 @@ import javax.swing.*;
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class FindReplace extends JFrame implements ActionListener {
|
public class FindReplace extends JFrame implements ActionListener {
|
||||||
|
|
||||||
static final int EDGE = Base.isMacOS() ? 20 : 13;
|
static final int EDGE = OSUtils.isMacOS() ? 20 : 13;
|
||||||
static final int SMALL = 6;
|
static final int SMALL = 6;
|
||||||
static final int BUTTONGAP = 12; // 12 is correct for Mac, other numbers may be required for other platofrms
|
static final int BUTTONGAP = 12; // 12 is correct for Mac, other numbers may be required for other platofrms
|
||||||
|
|
||||||
|
@ -143,7 +146,7 @@ public class FindReplace extends JFrame implements ActionListener {
|
||||||
buttons.setLayout(new FlowLayout(FlowLayout.CENTER, BUTTONGAP, 0));
|
buttons.setLayout(new FlowLayout(FlowLayout.CENTER, BUTTONGAP, 0));
|
||||||
|
|
||||||
// ordering is different on mac versus pc
|
// ordering is different on mac versus pc
|
||||||
if (Base.isMacOS()) {
|
if (OSUtils.isMacOS()) {
|
||||||
buttons.add(replaceAllButton = new JButton(_("Replace All")));
|
buttons.add(replaceAllButton = new JButton(_("Replace All")));
|
||||||
buttons.add(replaceButton = new JButton(_("Replace")));
|
buttons.add(replaceButton = new JButton(_("Replace")));
|
||||||
buttons.add(replaceFindButton = new JButton(_("Replace & Find")));
|
buttons.add(replaceFindButton = new JButton(_("Replace & Find")));
|
||||||
|
@ -161,7 +164,7 @@ public class FindReplace extends JFrame implements ActionListener {
|
||||||
|
|
||||||
// to fix ugliness.. normally macosx java 1.3 puts an
|
// to fix ugliness.. normally macosx java 1.3 puts an
|
||||||
// ugly white border around this object, so turn it off.
|
// ugly white border around this object, so turn it off.
|
||||||
if (Base.isMacOS()) {
|
if (OSUtils.isMacOS()) {
|
||||||
buttons.setBorder(null);
|
buttons.setBorder(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ import javax.swing.JTextField;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
|
|
||||||
import processing.app.helpers.FileUtils;
|
import processing.app.helpers.FileUtils;
|
||||||
|
import processing.app.helpers.OSUtils;
|
||||||
import processing.app.helpers.PreferencesHelper;
|
import processing.app.helpers.PreferencesHelper;
|
||||||
import processing.app.helpers.PreferencesMap;
|
import processing.app.helpers.PreferencesMap;
|
||||||
import processing.app.legacy.PApplet;
|
import processing.app.legacy.PApplet;
|
||||||
|
@ -405,7 +406,7 @@ public class Preferences {
|
||||||
|
|
||||||
// [ ] Automatically associate .pde files with Processing
|
// [ ] Automatically associate .pde files with Processing
|
||||||
|
|
||||||
if (Base.isWindows()) {
|
if (OSUtils.isWindows()) {
|
||||||
autoAssociateBox =
|
autoAssociateBox =
|
||||||
new JCheckBox(_("Automatically associate .ino files with Arduino"));
|
new JCheckBox(_("Automatically associate .ino files with Arduino"));
|
||||||
pain.add(autoAssociateBox);
|
pain.add(autoAssociateBox);
|
||||||
|
|
|
@ -25,12 +25,12 @@ package processing.app;
|
||||||
|
|
||||||
import cc.arduino.packages.BoardPort;
|
import cc.arduino.packages.BoardPort;
|
||||||
import cc.arduino.packages.UploaderAndMonitorFactory;
|
import cc.arduino.packages.UploaderAndMonitorFactory;
|
||||||
|
|
||||||
import cc.arduino.packages.Uploader;
|
import cc.arduino.packages.Uploader;
|
||||||
import processing.app.debug.*;
|
import processing.app.debug.*;
|
||||||
import processing.app.debug.Compiler;
|
import processing.app.debug.Compiler;
|
||||||
import processing.app.debug.Compiler.ProgressListener;
|
import processing.app.debug.Compiler.ProgressListener;
|
||||||
import processing.app.forms.PasswordAuthorizationDialog;
|
import processing.app.forms.PasswordAuthorizationDialog;
|
||||||
|
import processing.app.helpers.OSUtils;
|
||||||
import processing.app.helpers.PreferencesMap;
|
import processing.app.helpers.PreferencesMap;
|
||||||
import processing.app.helpers.FileUtils;
|
import processing.app.helpers.FileUtils;
|
||||||
import processing.app.packages.Library;
|
import processing.app.packages.Library;
|
||||||
|
@ -529,7 +529,7 @@ public class Sketch {
|
||||||
}
|
}
|
||||||
editor.header.repaint();
|
editor.header.repaint();
|
||||||
|
|
||||||
if (Base.isMacOS()) {
|
if (OSUtils.isMacOS()) {
|
||||||
// http://developer.apple.com/qa/qa2001/qa1146.html
|
// http://developer.apple.com/qa/qa2001/qa1146.html
|
||||||
Object modifiedParam = modified ? Boolean.TRUE : Boolean.FALSE;
|
Object modifiedParam = modified ? Boolean.TRUE : Boolean.FALSE;
|
||||||
editor.getRootPane().putClientProperty("windowModified", modifiedParam);
|
editor.getRootPane().putClientProperty("windowModified", modifiedParam);
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package processing.app.helpers;
|
||||||
|
|
||||||
|
public class OSUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns true if running on windows.
|
||||||
|
*/
|
||||||
|
static public boolean isWindows() {
|
||||||
|
//return PApplet.platform == PConstants.WINDOWS;
|
||||||
|
return System.getProperty("os.name").indexOf("Windows") != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* true if running on linux.
|
||||||
|
*/
|
||||||
|
static public boolean isLinux() {
|
||||||
|
//return PApplet.platform == PConstants.LINUX;
|
||||||
|
return System.getProperty("os.name").indexOf("Linux") != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns true if Processing is running on a Mac OS X machine.
|
||||||
|
*/
|
||||||
|
static public boolean isMacOS() {
|
||||||
|
//return PApplet.platform == PConstants.MACOSX;
|
||||||
|
return System.getProperty("os.name").indexOf("Mac") != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -31,7 +31,6 @@ import java.util.Map;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import processing.app.Base;
|
|
||||||
import processing.app.legacy.PApplet;
|
import processing.app.legacy.PApplet;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
|
@ -105,9 +104,9 @@ public class PreferencesMap extends LinkedHashMap<String, String> {
|
||||||
String key = line.substring(0, equals).trim();
|
String key = line.substring(0, equals).trim();
|
||||||
String value = line.substring(equals + 1).trim();
|
String value = line.substring(equals + 1).trim();
|
||||||
|
|
||||||
key = processPlatformSuffix(key, ".linux", Base.isLinux());
|
key = processPlatformSuffix(key, ".linux", OSUtils.isLinux());
|
||||||
key = processPlatformSuffix(key, ".windows", Base.isWindows());
|
key = processPlatformSuffix(key, ".windows", OSUtils.isWindows());
|
||||||
key = processPlatformSuffix(key, ".macosx", Base.isMacOS());
|
key = processPlatformSuffix(key, ".macosx", OSUtils.isMacOS());
|
||||||
|
|
||||||
if (key != null)
|
if (key != null)
|
||||||
put(key, value);
|
put(key, value);
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package processing.app.helpers;
|
package processing.app.helpers;
|
||||||
|
|
||||||
import processing.app.Base;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -9,7 +7,7 @@ public class ProcessUtils {
|
||||||
|
|
||||||
public static Process exec(String[] command) throws IOException {
|
public static Process exec(String[] command) throws IOException {
|
||||||
// No problems on linux and mac
|
// No problems on linux and mac
|
||||||
if (!Base.isWindows()) {
|
if (!OSUtils.isWindows()) {
|
||||||
return Runtime.getRuntime().exec(command);
|
return Runtime.getRuntime().exec(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
package processing.app.syntax;
|
package processing.app.syntax;
|
||||||
|
|
||||||
import processing.app.*;
|
import processing.app.*;
|
||||||
|
import processing.app.helpers.OSUtils;
|
||||||
|
|
||||||
|
|
||||||
public class PdeTextAreaDefaults extends TextAreaDefaults {
|
public class PdeTextAreaDefaults extends TextAreaDefaults {
|
||||||
|
@ -35,7 +36,7 @@ public class PdeTextAreaDefaults extends TextAreaDefaults {
|
||||||
//inputHandler.addDefaultKeyBindings(); // 0122
|
//inputHandler.addDefaultKeyBindings(); // 0122
|
||||||
|
|
||||||
// use option on mac for text edit controls that are ctrl on windows/linux
|
// use option on mac for text edit controls that are ctrl on windows/linux
|
||||||
String mod = Base.isMacOS() ? "A" : "C";
|
String mod = OSUtils.isMacOS() ? "A" : "C";
|
||||||
|
|
||||||
// right now, ctrl-up/down is select up/down, but mod should be
|
// right now, ctrl-up/down is select up/down, but mod should be
|
||||||
// used instead, because the mac expects it to be option(alt)
|
// used instead, because the mac expects it to be option(alt)
|
||||||
|
@ -94,7 +95,7 @@ public class PdeTextAreaDefaults extends TextAreaDefaults {
|
||||||
inputHandler.addKeyBinding("CS+END", InputHandler.SELECT_DOC_END);
|
inputHandler.addKeyBinding("CS+END", InputHandler.SELECT_DOC_END);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Base.isMacOS()) {
|
if (OSUtils.isMacOS()) {
|
||||||
inputHandler.addKeyBinding("M+LEFT", InputHandler.HOME);
|
inputHandler.addKeyBinding("M+LEFT", InputHandler.HOME);
|
||||||
inputHandler.addKeyBinding("M+RIGHT", InputHandler.END);
|
inputHandler.addKeyBinding("M+RIGHT", InputHandler.END);
|
||||||
inputHandler.addKeyBinding("MS+LEFT", InputHandler.SELECT_HOME); // 0122
|
inputHandler.addKeyBinding("MS+LEFT", InputHandler.SELECT_HOME); // 0122
|
||||||
|
|
Loading…
Reference in New Issue