mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-01 12:24:14 +01:00
Merged 1.0.4 pre-release into 1.5
This commit is contained in:
commit
b56034e785
@ -113,6 +113,11 @@ public class Base {
|
||||
|
||||
|
||||
static public void main(String args[]) throws Exception {
|
||||
initPlatform();
|
||||
|
||||
// run static initialization that grabs all the prefs
|
||||
Preferences.init(null);
|
||||
|
||||
try {
|
||||
File versionFile = getContentFile("lib/version.txt");
|
||||
if (versionFile.exists()) {
|
||||
@ -151,8 +156,6 @@ public class Base {
|
||||
}
|
||||
*/
|
||||
|
||||
initPlatform();
|
||||
|
||||
// // Set the look and feel before opening the window
|
||||
// try {
|
||||
// platform.setLookAndFeel();
|
||||
@ -172,12 +175,6 @@ public class Base {
|
||||
// Make sure a full JDK is installed
|
||||
//initRequirements();
|
||||
|
||||
// run static initialization that grabs all the prefs
|
||||
Preferences.init(null);
|
||||
|
||||
// load the I18n module for internationalization
|
||||
I18n.init(Preferences.get("editor.languages.current"));
|
||||
|
||||
// setup the theme coloring fun
|
||||
Theme.init();
|
||||
|
||||
|
@ -290,8 +290,8 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
|
||||
|
||||
protected void setup() {
|
||||
if (okButton == null) {
|
||||
cancelButton = new JButton(Preferences.PROMPT_CANCEL);
|
||||
okButton = new JButton(Preferences.PROMPT_OK);
|
||||
cancelButton = new JButton(I18n.PROMPT_CANCEL);
|
||||
okButton = new JButton(I18n.PROMPT_OK);
|
||||
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
@ -19,15 +19,29 @@ import java.text.MessageFormat;
|
||||
|
||||
public class I18n {
|
||||
// start using current locale but still allow using the dropdown list later
|
||||
private static ResourceBundle i18n = ResourceBundle.getBundle("processing.app.Resources");
|
||||
public static Locale locale;
|
||||
private static ResourceBundle i18n;
|
||||
|
||||
// prompt text stuff
|
||||
|
||||
static String PROMPT_YES;
|
||||
static String PROMPT_NO;
|
||||
static String PROMPT_CANCEL;
|
||||
static String PROMPT_OK;
|
||||
static String PROMPT_BROWSE;
|
||||
|
||||
static protected void init (String language) {
|
||||
// there might be a null pointer exception ... most likely will never happen but the jvm gets mad
|
||||
try {
|
||||
if (language == null || language.trim().length() == 0) locale = Locale.getDefault();
|
||||
else locale = new Locale(language);
|
||||
i18n = ResourceBundle.getBundle("processing.app.Resources", locale);
|
||||
if (language != null && language.trim().length() > 0) {
|
||||
Locale.setDefault(new Locale(language));
|
||||
}
|
||||
i18n = ResourceBundle.getBundle("processing.app.Resources", Locale.getDefault());
|
||||
|
||||
PROMPT_YES = _("Yes");
|
||||
PROMPT_NO = _("No");
|
||||
PROMPT_CANCEL = _("Cancel");
|
||||
PROMPT_OK = _("OK");
|
||||
PROMPT_BROWSE = _("Browse");
|
||||
} catch (java.lang.NullPointerException e) {
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import javax.swing.UIManager;
|
||||
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Native;
|
||||
import processing.core.PConstants;
|
||||
|
||||
|
||||
/**
|
||||
@ -159,6 +160,10 @@ public class Platform {
|
||||
return clib.unsetenv(variable);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return PConstants.platformNames[PConstants.OTHER];
|
||||
}
|
||||
|
||||
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
|
@ -23,16 +23,17 @@
|
||||
|
||||
package processing.app;
|
||||
|
||||
import processing.app.syntax.SyntaxStyle;
|
||||
import processing.core.PApplet;
|
||||
import processing.core.PConstants;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
import processing.app.syntax.*;
|
||||
import processing.core.*;
|
||||
import static processing.app.I18n._;
|
||||
|
||||
|
||||
@ -71,15 +72,6 @@ public class Preferences {
|
||||
|
||||
static final String PREFS_FILE = "preferences.txt";
|
||||
|
||||
|
||||
// prompt text stuff
|
||||
|
||||
static final String PROMPT_YES = _("Yes");
|
||||
static final String PROMPT_NO = _("No");
|
||||
static final String PROMPT_CANCEL = _("Cancel");
|
||||
static final String PROMPT_OK = _("OK");
|
||||
static final String PROMPT_BROWSE = _("Browse");
|
||||
|
||||
String[] languages = {
|
||||
_("System Default"),
|
||||
"العربية" + " (" + _("Arabic") + ")",
|
||||
@ -228,7 +220,7 @@ public class Preferences {
|
||||
table.put("runtime.ide.version", "" + Base.REVISION);
|
||||
|
||||
// check for platform-specific properties in the defaults
|
||||
String platformExt = "." + PConstants.platformNames[PApplet.platform];
|
||||
String platformExt = "." + Base.platform.getName();
|
||||
int platformExtLength = platformExt.length();
|
||||
Enumeration e = table.keys();
|
||||
while (e.hasMoreElements()) {
|
||||
@ -244,9 +236,6 @@ public class Preferences {
|
||||
// clone the hash table
|
||||
defaults = (Hashtable) table.clone();
|
||||
|
||||
// other things that have to be set explicitly for the defaults
|
||||
setColor("run.window.bgcolor", SystemColor.control);
|
||||
|
||||
// Load a prefs file if specified on the command line
|
||||
if (commandLinePrefs != null) {
|
||||
try {
|
||||
@ -284,6 +273,12 @@ public class Preferences {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// load the I18n module for internationalization
|
||||
I18n.init(Preferences.get("editor.languages.current"));
|
||||
|
||||
// other things that have to be set explicitly for the defaults
|
||||
setColor("run.window.bgcolor", SystemColor.control);
|
||||
}
|
||||
|
||||
|
||||
@ -322,7 +317,7 @@ public class Preferences {
|
||||
pain.add(sketchbookLocationField);
|
||||
d = sketchbookLocationField.getPreferredSize();
|
||||
|
||||
button = new JButton(PROMPT_BROWSE);
|
||||
button = new JButton(I18n.PROMPT_BROWSE);
|
||||
button.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
File dflt = new File(sketchbookLocationField.getText());
|
||||
@ -486,7 +481,7 @@ public class Preferences {
|
||||
|
||||
// [ OK ] [ Cancel ] maybe these should be next to the message?
|
||||
|
||||
button = new JButton(PROMPT_OK);
|
||||
button = new JButton(I18n.PROMPT_OK);
|
||||
button.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
applyFrame();
|
||||
@ -501,7 +496,7 @@ public class Preferences {
|
||||
button.setBounds(h, top, BUTTON_WIDTH, BUTTON_HEIGHT);
|
||||
h += BUTTON_WIDTH + GUI_SMALL;
|
||||
|
||||
button = new JButton(PROMPT_CANCEL);
|
||||
button = new JButton(I18n.PROMPT_CANCEL);
|
||||
button.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
disposeFrame();
|
||||
@ -683,7 +678,7 @@ public class Preferences {
|
||||
}
|
||||
|
||||
static public void load(InputStream input, Map table) throws IOException {
|
||||
String[] lines = PApplet.loadStrings(input); // Reads as UTF-8
|
||||
String[] lines = loadStrings(input); // Reads as UTF-8
|
||||
for (String line : lines) {
|
||||
if ((line.length() == 0) ||
|
||||
(line.charAt(0) == '#')) continue;
|
||||
@ -698,6 +693,41 @@ public class Preferences {
|
||||
}
|
||||
}
|
||||
|
||||
static public String[] loadStrings(InputStream input) {
|
||||
try {
|
||||
BufferedReader reader =
|
||||
new BufferedReader(new InputStreamReader(input, "UTF-8"));
|
||||
|
||||
String lines[] = new String[100];
|
||||
int lineCount = 0;
|
||||
String line = null;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if (lineCount == lines.length) {
|
||||
String temp[] = new String[lineCount << 1];
|
||||
System.arraycopy(lines, 0, temp, 0, lineCount);
|
||||
lines = temp;
|
||||
}
|
||||
lines[lineCount++] = line;
|
||||
}
|
||||
reader.close();
|
||||
|
||||
if (lineCount == lines.length) {
|
||||
return lines;
|
||||
}
|
||||
|
||||
// resize array to appropriate amount for these lines
|
||||
String output[] = new String[lineCount];
|
||||
System.arraycopy(lines, 0, output, 0, lineCount);
|
||||
return output;
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
//throw new RuntimeException("Error inside loadStrings()");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// .................................................................
|
||||
|
||||
|
@ -27,6 +27,7 @@ import java.io.File;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import processing.app.Preferences;
|
||||
import processing.core.PConstants;
|
||||
|
||||
|
||||
/**
|
||||
@ -112,4 +113,9 @@ public class Platform extends processing.app.Platform {
|
||||
file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return PConstants.platformNames[PConstants.LINUX];
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ import com.apple.eio.FileManager;
|
||||
|
||||
import processing.app.Base;
|
||||
import processing.core.PApplet;
|
||||
import processing.core.PConstants;
|
||||
|
||||
|
||||
/**
|
||||
@ -195,4 +196,10 @@ public class Platform extends processing.app.Platform {
|
||||
protected String getDocumentsFolder() throws FileNotFoundException {
|
||||
return FileManager.findFolder(kUserDomain, kDocumentsFolderType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return PConstants.platformNames[PConstants.MACOSX];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ import processing.app.Base;
|
||||
import processing.app.Preferences;
|
||||
import processing.app.windows.Registry.REGISTRY_ROOT_KEY;
|
||||
import processing.core.PApplet;
|
||||
import processing.core.PConstants;
|
||||
|
||||
|
||||
// http://developer.apple.com/documentation/QuickTime/Conceptual/QT7Win_Update_Guide/Chapter03/chapter_3_section_1.html
|
||||
@ -302,4 +303,10 @@ public class Platform extends processing.app.Platform {
|
||||
//return 0;
|
||||
return clib._putenv(variable + "=");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return PConstants.platformNames[PConstants.WINDOWS];
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user