mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-26 20:54:22 +01:00
Preparing the ground for rewriting Preferences GUI code (and hopefully fixing the tiny-pref-window bug on macosx)
This commit is contained in:
parent
7e7a9d0fe8
commit
9b58812d1d
@ -45,7 +45,7 @@ import java.io.*;
|
|||||||
|
|
||||||
public void show() {
|
public void show() {
|
||||||
String originalText = editor.textarea.getText();
|
String originalText = editor.textarea.getText();
|
||||||
int indentSize = Preferences.getInteger("editor.tabs.size");
|
int indentSize = PreferencesData.getInteger("editor.tabs.size");
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ public abstract class AbstractMonitor extends JFrame implements ActionListener {
|
|||||||
getContentPane().setLayout(new BorderLayout());
|
getContentPane().setLayout(new BorderLayout());
|
||||||
|
|
||||||
Font consoleFont = Theme.getFont("console.font");
|
Font consoleFont = Theme.getFont("console.font");
|
||||||
Font editorFont = Preferences.getFont("editor.font");
|
Font editorFont = PreferencesData.getFont("editor.font");
|
||||||
Font font = new Font(consoleFont.getName(), consoleFont.getStyle(), editorFont.getSize());
|
Font font = new Font(consoleFont.getName(), consoleFont.getStyle(), editorFont.getSize());
|
||||||
|
|
||||||
textArea = new TextAreaFIFO(8000000);
|
textArea = new TextAreaFIFO(8000000);
|
||||||
@ -124,12 +124,12 @@ public abstract class AbstractMonitor extends JFrame implements ActionListener {
|
|||||||
lineEndings = new JComboBox(new String[]{_("No line ending"), _("Newline"), _("Carriage return"), _("Both NL & CR")});
|
lineEndings = new JComboBox(new String[]{_("No line ending"), _("Newline"), _("Carriage return"), _("Both NL & CR")});
|
||||||
lineEndings.addActionListener(new ActionListener() {
|
lineEndings.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
Preferences.setInteger("serial.line_ending", lineEndings.getSelectedIndex());
|
PreferencesData.setInteger("serial.line_ending", lineEndings.getSelectedIndex());
|
||||||
noLineEndingAlert.setForeground(pane.getBackground());
|
noLineEndingAlert.setForeground(pane.getBackground());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (Preferences.get("serial.line_ending") != null) {
|
if (PreferencesData.get("serial.line_ending") != null) {
|
||||||
lineEndings.setSelectedIndex(Preferences.getInteger("serial.line_ending"));
|
lineEndings.setSelectedIndex(PreferencesData.getInteger("serial.line_ending"));
|
||||||
}
|
}
|
||||||
lineEndings.setMaximumSize(lineEndings.getMinimumSize());
|
lineEndings.setMaximumSize(lineEndings.getMinimumSize());
|
||||||
|
|
||||||
@ -160,13 +160,13 @@ public abstract class AbstractMonitor extends JFrame implements ActionListener {
|
|||||||
pack();
|
pack();
|
||||||
|
|
||||||
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
|
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
if (Preferences.get("last.screen.height") != null) {
|
if (PreferencesData.get("last.screen.height") != null) {
|
||||||
// if screen size has changed, the window coordinates no longer
|
// if screen size has changed, the window coordinates no longer
|
||||||
// make sense, so don't use them unless they're identical
|
// make sense, so don't use them unless they're identical
|
||||||
int screenW = Preferences.getInteger("last.screen.width");
|
int screenW = PreferencesData.getInteger("last.screen.width");
|
||||||
int screenH = Preferences.getInteger("last.screen.height");
|
int screenH = PreferencesData.getInteger("last.screen.height");
|
||||||
if ((screen.width == screenW) && (screen.height == screenH)) {
|
if ((screen.width == screenW) && (screen.height == screenH)) {
|
||||||
String locationStr = Preferences.get("last.serial.location");
|
String locationStr = PreferencesData.get("last.serial.location");
|
||||||
if (locationStr != null) {
|
if (locationStr != null) {
|
||||||
int[] location = PApplet.parseInt(PApplet.split(locationStr, ','));
|
int[] location = PApplet.parseInt(PApplet.split(locationStr, ','));
|
||||||
setPlacement(location);
|
setPlacement(location);
|
||||||
|
@ -143,7 +143,7 @@ public class Base {
|
|||||||
|
|
||||||
BaseNoGui.initParameters(args);
|
BaseNoGui.initParameters(args);
|
||||||
|
|
||||||
System.setProperty("swing.aatext", Preferences.get("editor.antialias", "true"));
|
System.setProperty("swing.aatext", PreferencesData.get("editor.antialias", "true"));
|
||||||
|
|
||||||
BaseNoGui.initVersion();
|
BaseNoGui.initVersion();
|
||||||
|
|
||||||
@ -257,9 +257,9 @@ public class Base {
|
|||||||
if (sketchbookPath == null) {
|
if (sketchbookPath == null) {
|
||||||
File defaultFolder = getDefaultSketchbookFolderOrPromptForIt();
|
File defaultFolder = getDefaultSketchbookFolderOrPromptForIt();
|
||||||
if (BaseNoGui.getPortableFolder() != null)
|
if (BaseNoGui.getPortableFolder() != null)
|
||||||
Preferences.set("sketchbook.path", BaseNoGui.getPortableSketchbookFolder());
|
PreferencesData.set("sketchbook.path", BaseNoGui.getPortableSketchbookFolder());
|
||||||
else
|
else
|
||||||
Preferences.set("sketchbook.path", defaultFolder.getAbsolutePath());
|
PreferencesData.set("sketchbook.path", defaultFolder.getAbsolutePath());
|
||||||
if (!defaultFolder.exists()) {
|
if (!defaultFolder.exists()) {
|
||||||
defaultFolder.mkdirs();
|
defaultFolder.mkdirs();
|
||||||
}
|
}
|
||||||
@ -293,7 +293,7 @@ public class Base {
|
|||||||
|
|
||||||
boolean showEditor = parser.isGuiMode();
|
boolean showEditor = parser.isGuiMode();
|
||||||
if (!parser.isForceSavePrefs())
|
if (!parser.isForceSavePrefs())
|
||||||
Preferences.setDoSave(showEditor);
|
PreferencesData.setDoSave(showEditor);
|
||||||
if (handleOpen(file, nextEditorLocation(), showEditor) == null) {
|
if (handleOpen(file, nextEditorLocation(), showEditor) == null) {
|
||||||
String mess = I18n.format(_("Failed to open sketch: \"{0}\""), path);
|
String mess = I18n.format(_("Failed to open sketch: \"{0}\""), path);
|
||||||
// Open failure is fatal in upload/verify mode
|
// Open failure is fatal in upload/verify mode
|
||||||
@ -406,13 +406,13 @@ public class Base {
|
|||||||
} else if (parser.isVerifyOrUploadMode()) {
|
} else if (parser.isVerifyOrUploadMode()) {
|
||||||
splashScreenHelper.close();
|
splashScreenHelper.close();
|
||||||
// Set verbosity for command line build
|
// Set verbosity for command line build
|
||||||
Preferences.set("build.verbose", "" + parser.isDoVerboseBuild());
|
PreferencesData.set("build.verbose", "" + parser.isDoVerboseBuild());
|
||||||
Preferences.set("upload.verbose", "" + parser.isDoVerboseUpload());
|
PreferencesData.set("upload.verbose", "" + parser.isDoVerboseUpload());
|
||||||
Preferences.set("runtime.preserve.temp.files", Boolean.toString(parser.isPreserveTempFiles()));
|
PreferencesData.set("runtime.preserve.temp.files", Boolean.toString(parser.isPreserveTempFiles()));
|
||||||
|
|
||||||
// Make sure these verbosity preferences are only for the
|
// Make sure these verbosity preferences are only for the
|
||||||
// current session
|
// current session
|
||||||
Preferences.setDoSave(false);
|
PreferencesData.setDoSave(false);
|
||||||
|
|
||||||
Editor editor = editors.get(0);
|
Editor editor = editors.get(0);
|
||||||
|
|
||||||
@ -443,14 +443,14 @@ public class Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for updates
|
// Check for updates
|
||||||
if (Preferences.getBoolean("update.check")) {
|
if (PreferencesData.getBoolean("update.check")) {
|
||||||
new UpdateCheck(this);
|
new UpdateCheck(this);
|
||||||
}
|
}
|
||||||
} else if (parser.isNoOpMode()) {
|
} else if (parser.isNoOpMode()) {
|
||||||
// Do nothing (intended for only changing preferences)
|
// Do nothing (intended for only changing preferences)
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
} else if (parser.isGetPrefMode()) {
|
} else if (parser.isGetPrefMode()) {
|
||||||
String value = Preferences.get(parser.getGetPref(), null);
|
String value = PreferencesData.get(parser.getGetPref(), null);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
System.out.println(value);
|
System.out.println(value);
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
@ -474,11 +474,11 @@ public class Base {
|
|||||||
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
|
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
boolean windowPositionValid = true;
|
boolean windowPositionValid = true;
|
||||||
|
|
||||||
if (Preferences.get("last.screen.height") != null) {
|
if (PreferencesData.get("last.screen.height") != null) {
|
||||||
// if screen size has changed, the window coordinates no longer
|
// if screen size has changed, the window coordinates no longer
|
||||||
// make sense, so don't use them unless they're identical
|
// make sense, so don't use them unless they're identical
|
||||||
int screenW = Preferences.getInteger("last.screen.width");
|
int screenW = PreferencesData.getInteger("last.screen.width");
|
||||||
int screenH = Preferences.getInteger("last.screen.height");
|
int screenH = PreferencesData.getInteger("last.screen.height");
|
||||||
|
|
||||||
if ((screen.width != screenW) || (screen.height != screenH)) {
|
if ((screen.width != screenW) || (screen.height != screenH)) {
|
||||||
windowPositionValid = false;
|
windowPositionValid = false;
|
||||||
@ -499,10 +499,10 @@ public class Base {
|
|||||||
// If !windowPositionValid, then ignore the coordinates found for each.
|
// If !windowPositionValid, then ignore the coordinates found for each.
|
||||||
|
|
||||||
// Save the sketch path and window placement for each open sketch
|
// Save the sketch path and window placement for each open sketch
|
||||||
int count = Preferences.getInteger("last.sketch.count");
|
int count = PreferencesData.getInteger("last.sketch.count");
|
||||||
int opened = 0;
|
int opened = 0;
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
String path = Preferences.get("last.sketch" + i + ".path");
|
String path = PreferencesData.get("last.sketch" + i + ".path");
|
||||||
if (BaseNoGui.getPortableFolder() != null) {
|
if (BaseNoGui.getPortableFolder() != null) {
|
||||||
File absolute = new File(BaseNoGui.getPortableFolder(), path);
|
File absolute = new File(BaseNoGui.getPortableFolder(), path);
|
||||||
try {
|
try {
|
||||||
@ -513,7 +513,7 @@ public class Base {
|
|||||||
}
|
}
|
||||||
int[] location;
|
int[] location;
|
||||||
if (windowPositionValid) {
|
if (windowPositionValid) {
|
||||||
String locationStr = Preferences.get("last.sketch" + i + ".location");
|
String locationStr = PreferencesData.get("last.sketch" + i + ".location");
|
||||||
location = PApplet.parseInt(PApplet.split(locationStr, ','));
|
location = PApplet.parseInt(PApplet.split(locationStr, ','));
|
||||||
} else {
|
} else {
|
||||||
location = nextEditorLocation();
|
location = nextEditorLocation();
|
||||||
@ -534,8 +534,8 @@ public class Base {
|
|||||||
protected void storeSketches() {
|
protected void storeSketches() {
|
||||||
// Save the width and height of the screen
|
// Save the width and height of the screen
|
||||||
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
|
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
Preferences.setInteger("last.screen.width", screen.width);
|
PreferencesData.setInteger("last.screen.width", screen.width);
|
||||||
Preferences.setInteger("last.screen.height", screen.height);
|
PreferencesData.setInteger("last.screen.height", screen.height);
|
||||||
|
|
||||||
String untitledPath = untitledFolder.getAbsolutePath();
|
String untitledPath = untitledFolder.getAbsolutePath();
|
||||||
|
|
||||||
@ -554,14 +554,14 @@ public class Base {
|
|||||||
if (path == null)
|
if (path == null)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Preferences.set("last.sketch" + index + ".path", path);
|
PreferencesData.set("last.sketch" + index + ".path", path);
|
||||||
|
|
||||||
int[] location = editor.getPlacement();
|
int[] location = editor.getPlacement();
|
||||||
String locationStr = PApplet.join(PApplet.str(location), ",");
|
String locationStr = PApplet.join(PApplet.str(location), ",");
|
||||||
Preferences.set("last.sketch" + index + ".location", locationStr);
|
PreferencesData.set("last.sketch" + index + ".location", locationStr);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
Preferences.setInteger("last.sketch.count", index);
|
PreferencesData.setInteger("last.sketch.count", index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -577,7 +577,7 @@ public class Base {
|
|||||||
if (path == null)
|
if (path == null)
|
||||||
path = "";
|
path = "";
|
||||||
}
|
}
|
||||||
Preferences.set("last.sketch" + index + ".path", path);
|
PreferencesData.set("last.sketch" + index + ".path", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -616,8 +616,8 @@ public class Base {
|
|||||||
|
|
||||||
|
|
||||||
protected int[] nextEditorLocation() {
|
protected int[] nextEditorLocation() {
|
||||||
int defaultWidth = Preferences.getInteger("editor.window.width.default");
|
int defaultWidth = PreferencesData.getInteger("editor.window.width.default");
|
||||||
int defaultHeight = Preferences.getInteger("editor.window.height.default");
|
int defaultHeight = PreferencesData.getInteger("editor.window.height.default");
|
||||||
|
|
||||||
if (activeEditor == null) {
|
if (activeEditor == null) {
|
||||||
Rectangle screen = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().getBounds();
|
Rectangle screen = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().getBounds();
|
||||||
@ -808,7 +808,7 @@ public class Base {
|
|||||||
public void handleOpenPrompt() throws Exception {
|
public void handleOpenPrompt() throws Exception {
|
||||||
// get the frontmost window frame for placing file dialog
|
// get the frontmost window frame for placing file dialog
|
||||||
FileDialog fd = new FileDialog(activeEditor, _("Open an Arduino sketch..."), FileDialog.LOAD);
|
FileDialog fd = new FileDialog(activeEditor, _("Open an Arduino sketch..."), FileDialog.LOAD);
|
||||||
File lastFolder = new File(Preferences.get("last.folder", getSketchbookFolder().getAbsolutePath()));
|
File lastFolder = new File(PreferencesData.get("last.folder", getSketchbookFolder().getAbsolutePath()));
|
||||||
if (lastFolder.exists() && lastFolder.isFile()) {
|
if (lastFolder.exists() && lastFolder.isFile()) {
|
||||||
lastFolder = lastFolder.getParentFile();
|
lastFolder = lastFolder.getParentFile();
|
||||||
}
|
}
|
||||||
@ -832,7 +832,7 @@ public class Base {
|
|||||||
|
|
||||||
File inputFile = new File(directory, filename);
|
File inputFile = new File(directory, filename);
|
||||||
|
|
||||||
Preferences.set("last.folder", inputFile.getAbsolutePath());
|
PreferencesData.set("last.folder", inputFile.getAbsolutePath());
|
||||||
handleOpen(inputFile);
|
handleOpen(inputFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1378,9 +1378,9 @@ public class Base {
|
|||||||
Map<String, ButtonGroup> buttonGroupsMap,
|
Map<String, ButtonGroup> buttonGroupsMap,
|
||||||
TargetBoard board, TargetPlatform targetPlatform, TargetPackage targetPackage)
|
TargetBoard board, TargetPlatform targetPlatform, TargetPackage targetPackage)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
String selPackage = Preferences.get("target_package");
|
String selPackage = PreferencesData.get("target_package");
|
||||||
String selPlatform = Preferences.get("target_platform");
|
String selPlatform = PreferencesData.get("target_platform");
|
||||||
String selBoard = Preferences.get("board");
|
String selBoard = PreferencesData.get("board");
|
||||||
|
|
||||||
String boardId = board.getId();
|
String boardId = board.getId();
|
||||||
String packageName = targetPackage.getId();
|
String packageName = targetPackage.getId();
|
||||||
@ -1418,7 +1418,7 @@ public class Base {
|
|||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
Action subAction = new AbstractAction(_(boardCustomMenu.get(customMenuOption))) {
|
Action subAction = new AbstractAction(_(boardCustomMenu.get(customMenuOption))) {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
Preferences.set("custom_" + menuId, ((TargetBoard) getValue("board")).getId() + "_" + getValue("custom_menu_option"));
|
PreferencesData.set("custom_" + menuId, ((TargetBoard) getValue("board")).getId() + "_" + getValue("custom_menu_option"));
|
||||||
onBoardOrPortChange();
|
onBoardOrPortChange();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1433,7 +1433,7 @@ public class Base {
|
|||||||
menu.add(subItem);
|
menu.add(subItem);
|
||||||
buttonGroupsMap.get(menuId).add(subItem);
|
buttonGroupsMap.get(menuId).add(subItem);
|
||||||
|
|
||||||
String selectedCustomMenuEntry = Preferences.get("custom_" + menuId);
|
String selectedCustomMenuEntry = PreferencesData.get("custom_" + menuId);
|
||||||
if (selBoard.equals(boardId) && (boardId + "_" + customMenuOption).equals(selectedCustomMenuEntry)) {
|
if (selBoard.equals(boardId) && (boardId + "_" + customMenuOption).equals(selectedCustomMenuEntry)) {
|
||||||
menuItemsToClickAfterStartup.add(subItem);
|
menuItemsToClickAfterStartup.add(subItem);
|
||||||
}
|
}
|
||||||
@ -1534,12 +1534,12 @@ public class Base {
|
|||||||
AbstractAction action = new AbstractAction(targetPlatform
|
AbstractAction action = new AbstractAction(targetPlatform
|
||||||
.getProgrammer(programmer).get("name")) {
|
.getProgrammer(programmer).get("name")) {
|
||||||
public void actionPerformed(ActionEvent actionevent) {
|
public void actionPerformed(ActionEvent actionevent) {
|
||||||
Preferences.set("programmer", "" + getValue("id"));
|
PreferencesData.set("programmer", "" + getValue("id"));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
action.putValue("id", id);
|
action.putValue("id", id);
|
||||||
JMenuItem item = new JRadioButtonMenuItem(action);
|
JMenuItem item = new JRadioButtonMenuItem(action);
|
||||||
if (Preferences.get("programmer").equals(id))
|
if (PreferencesData.get("programmer").equals(id))
|
||||||
item.setSelected(true);
|
item.setSelected(true);
|
||||||
group.add(item);
|
group.add(item);
|
||||||
menu.add(item);
|
menu.add(item);
|
||||||
|
@ -24,9 +24,6 @@ package processing.app;
|
|||||||
|
|
||||||
import cc.arduino.packages.MonitorFactory;
|
import cc.arduino.packages.MonitorFactory;
|
||||||
|
|
||||||
import cc.arduino.view.*;
|
|
||||||
import cc.arduino.view.Event;
|
|
||||||
import cc.arduino.view.EventListener;
|
|
||||||
import com.jcraft.jsch.JSchException;
|
import com.jcraft.jsch.JSchException;
|
||||||
import jssc.SerialPortException;
|
import jssc.SerialPortException;
|
||||||
import processing.app.debug.*;
|
import processing.app.debug.*;
|
||||||
@ -280,7 +277,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
splitPane.setBorder(null);
|
splitPane.setBorder(null);
|
||||||
|
|
||||||
// the default size on windows is too small and kinda ugly
|
// the default size on windows is too small and kinda ugly
|
||||||
int dividerSize = Preferences.getInteger("editor.divider.size");
|
int dividerSize = PreferencesData.getInteger("editor.divider.size");
|
||||||
if (dividerSize != 0) {
|
if (dividerSize != 0) {
|
||||||
splitPane.setDividerSize(dividerSize);
|
splitPane.setDividerSize(dividerSize);
|
||||||
}
|
}
|
||||||
@ -312,8 +309,8 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
|
|
||||||
|
|
||||||
// Set the minimum size for the editor window
|
// Set the minimum size for the editor window
|
||||||
setMinimumSize(new Dimension(Preferences.getInteger("editor.window.width.min"),
|
setMinimumSize(new Dimension(PreferencesData.getInteger("editor.window.width.min"),
|
||||||
Preferences.getInteger("editor.window.height.min")));
|
PreferencesData.getInteger("editor.window.height.min")));
|
||||||
// System.out.println("t3");
|
// System.out.println("t3");
|
||||||
|
|
||||||
// Bring back the general options for the editor
|
// Bring back the general options for the editor
|
||||||
@ -445,13 +442,13 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
protected void applyPreferences() {
|
protected void applyPreferences() {
|
||||||
|
|
||||||
// apply the setting for 'use external editor'
|
// apply the setting for 'use external editor'
|
||||||
boolean external = Preferences.getBoolean("editor.external");
|
boolean external = PreferencesData.getBoolean("editor.external");
|
||||||
|
|
||||||
textarea.setEditable(!external);
|
textarea.setEditable(!external);
|
||||||
saveMenuItem.setEnabled(!external);
|
saveMenuItem.setEnabled(!external);
|
||||||
saveAsMenuItem.setEnabled(!external);
|
saveAsMenuItem.setEnabled(!external);
|
||||||
|
|
||||||
textarea.setDisplayLineNumbers(Preferences.getBoolean("editor.linenumbers"));
|
textarea.setDisplayLineNumbers(PreferencesData.getBoolean("editor.linenumbers"));
|
||||||
|
|
||||||
TextAreaPainter painter = textarea.getPainter();
|
TextAreaPainter painter = textarea.getPainter();
|
||||||
if (external) {
|
if (external) {
|
||||||
@ -464,14 +461,14 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
} else {
|
} else {
|
||||||
Color color = Theme.getColor("editor.bgcolor");
|
Color color = Theme.getColor("editor.bgcolor");
|
||||||
painter.setBackground(color);
|
painter.setBackground(color);
|
||||||
boolean highlight = Preferences.getBoolean("editor.linehighlight");
|
boolean highlight = PreferencesData.getBoolean("editor.linehighlight");
|
||||||
painter.setLineHighlightEnabled(highlight);
|
painter.setLineHighlightEnabled(highlight);
|
||||||
textarea.setCaretVisible(true);
|
textarea.setCaretVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply changes to the font size for the editor
|
// apply changes to the font size for the editor
|
||||||
//TextAreaPainter painter = textarea.getPainter();
|
//TextAreaPainter painter = textarea.getPainter();
|
||||||
painter.setFont(Preferences.getFont("editor.font"));
|
painter.setFont(PreferencesData.getFont("editor.font"));
|
||||||
//Font font = painter.getFont();
|
//Font font = painter.getFont();
|
||||||
//textarea.getPainter().setFont(new Font("Courier", Font.PLAIN, 36));
|
//textarea.getPainter().setFont(new Font("Courier", Font.PLAIN, 36));
|
||||||
|
|
||||||
@ -586,10 +583,10 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
|
|
||||||
item = newJMenuItemShift(_("Page Setup"), 'P');
|
item = newJMenuItemShift(_("Page Setup"), 'P');
|
||||||
item.addActionListener(new ActionListener() {
|
item.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
handlePageSetup();
|
handlePageSetup();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
fileMenu.add(item);
|
fileMenu.add(item);
|
||||||
|
|
||||||
item = newJMenuItem(_("Print"), 'P');
|
item = newJMenuItem(_("Print"), 'P');
|
||||||
@ -677,10 +674,10 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
|
|
||||||
item = new JMenuItem(_("Add File..."));
|
item = new JMenuItem(_("Add File..."));
|
||||||
item.addActionListener(new ActionListener() {
|
item.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
sketch.handleAddFile();
|
sketch.handleAddFile();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
sketchMenu.add(item);
|
sketchMenu.add(item);
|
||||||
|
|
||||||
return sketchMenu;
|
return sketchMenu;
|
||||||
@ -1023,11 +1020,11 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
protected void populatePortMenu() {
|
protected void populatePortMenu() {
|
||||||
serialMenu.removeAll();
|
serialMenu.removeAll();
|
||||||
|
|
||||||
String selectedPort = Preferences.get("serial.port");
|
String selectedPort = PreferencesData.get("serial.port");
|
||||||
|
|
||||||
List<BoardPort> ports = Base.getDiscoveryManager().discovery();
|
List<BoardPort> ports = Base.getDiscoveryManager().discovery();
|
||||||
|
|
||||||
ports = Base.getPlatform().filterPorts(ports, Preferences.getBoolean("serial.ports.showall"));
|
ports = Base.getPlatform().filterPorts(ports, PreferencesData.getBoolean("serial.ports.showall"));
|
||||||
|
|
||||||
Collections.sort(ports, new Comparator<BoardPort>() {
|
Collections.sort(ports, new Comparator<BoardPort>() {
|
||||||
@Override
|
@Override
|
||||||
@ -1891,7 +1888,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
|
|
||||||
|
|
||||||
protected void handleIndentOutdent(boolean indent) {
|
protected void handleIndentOutdent(boolean indent) {
|
||||||
int tabSize = Preferences.getInteger("editor.tabs.size");
|
int tabSize = PreferencesData.getInteger("editor.tabs.size");
|
||||||
String tabString = Editor.EMPTY.substring(0, tabSize);
|
String tabString = Editor.EMPTY.substring(0, tabSize);
|
||||||
|
|
||||||
startCompoundEdit();
|
startCompoundEdit();
|
||||||
@ -1994,7 +1991,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
*/
|
*/
|
||||||
public void handleRun(final boolean verbose) {
|
public void handleRun(final boolean verbose) {
|
||||||
internalCloseRunner();
|
internalCloseRunner();
|
||||||
if (Preferences.getBoolean("editor.save_on_verify")) {
|
if (PreferencesData.getBoolean("editor.save_on_verify")) {
|
||||||
if (sketch.isModified() && !sketch.isReadOnly()) {
|
if (sketch.isModified() && !sketch.isReadOnly()) {
|
||||||
handleSave(true);
|
handleSave(true);
|
||||||
}
|
}
|
||||||
@ -2007,7 +2004,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
for (int i = 0; i < 10; i++) System.out.println();
|
for (int i = 0; i < 10; i++) System.out.println();
|
||||||
|
|
||||||
// clear the console on each run, unless the user doesn't want to
|
// clear the console on each run, unless the user doesn't want to
|
||||||
if (Preferences.getBoolean("console.auto_clear")) {
|
if (PreferencesData.getBoolean("console.auto_clear")) {
|
||||||
console.clear();
|
console.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2433,7 +2430,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
I18n.format(
|
I18n.format(
|
||||||
_("Serial port {0} not found.\n" +
|
_("Serial port {0} not found.\n" +
|
||||||
"Retry the upload with another serial port?"),
|
"Retry the upload with another serial port?"),
|
||||||
Preferences.get("serial.port")
|
PreferencesData.get("serial.port")
|
||||||
),
|
),
|
||||||
"Serial port not found",
|
"Serial port not found",
|
||||||
JOptionPane.PLAIN_MESSAGE,
|
JOptionPane.PLAIN_MESSAGE,
|
||||||
@ -2463,7 +2460,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
* hitting export twice, quickly, and horking things up.
|
* hitting export twice, quickly, and horking things up.
|
||||||
*/
|
*/
|
||||||
synchronized public void handleExport(final boolean usingProgrammer) {
|
synchronized public void handleExport(final boolean usingProgrammer) {
|
||||||
if (Preferences.getBoolean("editor.save_on_verify")) {
|
if (PreferencesData.getBoolean("editor.save_on_verify")) {
|
||||||
if (sketch.isModified() && !sketch.isReadOnly()) {
|
if (sketch.isModified() && !sketch.isReadOnly()) {
|
||||||
handleSave(true);
|
handleSave(true);
|
||||||
}
|
}
|
||||||
@ -2606,10 +2603,10 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BoardPort port = Base.getDiscoveryManager().find(Preferences.get("serial.port"));
|
BoardPort port = Base.getDiscoveryManager().find(PreferencesData.get("serial.port"));
|
||||||
|
|
||||||
if (port == null) {
|
if (port == null) {
|
||||||
statusError(I18n.format("Board at {0} is not available", Preferences.get("serial.port")));
|
statusError(I18n.format("Board at {0} is not available", PreferencesData.get("serial.port")));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2618,7 +2615,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
|
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
do {
|
do {
|
||||||
if (serialMonitor.requiresAuthorization() && !Preferences.has(serialMonitor.getAuthorizationKey())) {
|
if (serialMonitor.requiresAuthorization() && !PreferencesData.has(serialMonitor.getAuthorizationKey())) {
|
||||||
PasswordAuthorizationDialog dialog = new PasswordAuthorizationDialog(this, _("Type board password to access its console"));
|
PasswordAuthorizationDialog dialog = new PasswordAuthorizationDialog(this, _("Type board password to access its console"));
|
||||||
dialog.setLocationRelativeTo(this);
|
dialog.setLocationRelativeTo(this);
|
||||||
dialog.setVisible(true);
|
dialog.setVisible(true);
|
||||||
@ -2628,7 +2625,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Preferences.set(serialMonitor.getAuthorizationKey(), dialog.getPassword());
|
PreferencesData.set(serialMonitor.getAuthorizationKey(), dialog.getPassword());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -2649,7 +2646,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
statusError(e);
|
statusError(e);
|
||||||
} finally {
|
} finally {
|
||||||
if (serialMonitor.requiresAuthorization() && !success) {
|
if (serialMonitor.requiresAuthorization() && !success) {
|
||||||
Preferences.remove(serialMonitor.getAuthorizationKey());
|
PreferencesData.remove(serialMonitor.getAuthorizationKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2829,7 +2826,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
lineStatus.setBoardName(boardPreferences.get("name"));
|
lineStatus.setBoardName(boardPreferences.get("name"));
|
||||||
else
|
else
|
||||||
lineStatus.setBoardName("-");
|
lineStatus.setBoardName("-");
|
||||||
lineStatus.setSerialPort(Preferences.get("serial.port"));
|
lineStatus.setSerialPort(PreferencesData.get("serial.port"));
|
||||||
lineStatus.repaint();
|
lineStatus.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ public class EditorConsole extends JScrollPane {
|
|||||||
public EditorConsole(Editor _editor) {
|
public EditorConsole(Editor _editor) {
|
||||||
editor = _editor;
|
editor = _editor;
|
||||||
|
|
||||||
int maxLineCount = Preferences.getInteger("console.length");
|
int maxLineCount = PreferencesData.getInteger("console.length");
|
||||||
|
|
||||||
consoleDoc = new BufferedStyledDocument(4000, maxLineCount);
|
consoleDoc = new BufferedStyledDocument(4000, maxLineCount);
|
||||||
consoleTextPane = new JTextPane(consoleDoc);
|
consoleTextPane = new JTextPane(consoleDoc);
|
||||||
@ -84,7 +84,7 @@ public class EditorConsole extends JScrollPane {
|
|||||||
Color fgColorOut = Theme.getColor("console.output.color");
|
Color fgColorOut = Theme.getColor("console.output.color");
|
||||||
Color fgColorErr = Theme.getColor("console.error.color");
|
Color fgColorErr = Theme.getColor("console.error.color");
|
||||||
Font consoleFont = Theme.getFont("console.font");
|
Font consoleFont = Theme.getFont("console.font");
|
||||||
Font editorFont = Preferences.getFont("editor.font");
|
Font editorFont = PreferencesData.getFont("editor.font");
|
||||||
Font font = new Font(consoleFont.getName(), consoleFont.getStyle(), editorFont.getSize());
|
Font font = new Font(consoleFont.getName(), consoleFont.getStyle(), editorFont.getSize());
|
||||||
|
|
||||||
stdStyle = new SimpleAttributeSet();
|
stdStyle = new SimpleAttributeSet();
|
||||||
@ -112,7 +112,7 @@ public class EditorConsole extends JScrollPane {
|
|||||||
// and size window accordingly
|
// and size window accordingly
|
||||||
FontMetrics metrics = getFontMetrics(font);
|
FontMetrics metrics = getFontMetrics(font);
|
||||||
int height = metrics.getAscent() + metrics.getDescent();
|
int height = metrics.getAscent() + metrics.getDescent();
|
||||||
int lines = Preferences.getInteger("console.lines");
|
int lines = PreferencesData.getInteger("console.lines");
|
||||||
int sizeFudge = 6; //10; // unclear why this is necessary, but it is
|
int sizeFudge = 6; //10; // unclear why this is necessary, but it is
|
||||||
setPreferredSize(new Dimension(1024, (height * lines) + sizeFudge));
|
setPreferredSize(new Dimension(1024, (height * lines) + sizeFudge));
|
||||||
setMinimumSize(new Dimension(1024, (height * 4) + sizeFudge));
|
setMinimumSize(new Dimension(1024, (height * 4) + sizeFudge));
|
||||||
|
@ -37,14 +37,14 @@ class EditorConsoleStream extends OutputStream {
|
|||||||
tempFolder = Base.createTempFolder("console");
|
tempFolder = Base.createTempFolder("console");
|
||||||
DeleteFilesOnShutdown.add(tempFolder);
|
DeleteFilesOnShutdown.add(tempFolder);
|
||||||
try {
|
try {
|
||||||
String outFileName = Preferences.get("console.output.file");
|
String outFileName = PreferencesData.get("console.output.file");
|
||||||
if (outFileName != null) {
|
if (outFileName != null) {
|
||||||
outFile = new File(tempFolder, outFileName);
|
outFile = new File(tempFolder, outFileName);
|
||||||
DeleteFilesOnShutdown.add(outFile);
|
DeleteFilesOnShutdown.add(outFile);
|
||||||
stdoutFile = new FileOutputStream(outFile);
|
stdoutFile = new FileOutputStream(outFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
String errFileName = Preferences.get("console.error.file");
|
String errFileName = PreferencesData.get("console.error.file");
|
||||||
if (errFileName != null) {
|
if (errFileName != null) {
|
||||||
errFile = new File(tempFolder, errFileName);
|
errFile = new File(tempFolder, errFileName);
|
||||||
DeleteFilesOnShutdown.add(errFile);
|
DeleteFilesOnShutdown.add(errFile);
|
||||||
@ -58,7 +58,7 @@ class EditorConsoleStream extends OutputStream {
|
|||||||
consoleOut = new PrintStream(new EditorConsoleStream(false));
|
consoleOut = new PrintStream(new EditorConsoleStream(false));
|
||||||
consoleErr = new PrintStream(new EditorConsoleStream(true));
|
consoleErr = new PrintStream(new EditorConsoleStream(true));
|
||||||
|
|
||||||
if (Preferences.getBoolean("console")) {
|
if (PreferencesData.getBoolean("console")) {
|
||||||
try {
|
try {
|
||||||
System.setOut(consoleOut);
|
System.setOut(consoleOut);
|
||||||
System.setErr(consoleErr);
|
System.setErr(consoleErr);
|
||||||
|
@ -101,7 +101,7 @@ public class EditorLineStatus extends JComponent {
|
|||||||
setBoardName(boardPreferences.get("name"));
|
setBoardName(boardPreferences.get("name"));
|
||||||
else
|
else
|
||||||
setBoardName("-");
|
setBoardName("-");
|
||||||
setSerialPort(Preferences.get("serial.port"));
|
setSerialPort(PreferencesData.get("serial.port"));
|
||||||
}
|
}
|
||||||
g.setColor(background);
|
g.setColor(background);
|
||||||
Dimension size = getSize();
|
Dimension size = getSize();
|
||||||
|
@ -73,12 +73,12 @@ public class EditorListener {
|
|||||||
|
|
||||||
|
|
||||||
public void applyPreferences() {
|
public void applyPreferences() {
|
||||||
tabsExpand = Preferences.getBoolean("editor.tabs.expand");
|
tabsExpand = PreferencesData.getBoolean("editor.tabs.expand");
|
||||||
//tabsIndent = Preferences.getBoolean("editor.tabs.indent");
|
//tabsIndent = Preferences.getBoolean("editor.tabs.indent");
|
||||||
tabSize = Preferences.getInteger("editor.tabs.size");
|
tabSize = PreferencesData.getInteger("editor.tabs.size");
|
||||||
tabString = Editor.EMPTY.substring(0, tabSize);
|
tabString = Editor.EMPTY.substring(0, tabSize);
|
||||||
autoIndent = Preferences.getBoolean("editor.indent");
|
autoIndent = PreferencesData.getBoolean("editor.indent");
|
||||||
externalEditor = Preferences.getBoolean("editor.external");
|
externalEditor = PreferencesData.getBoolean("editor.external");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
|
|||||||
|
|
||||||
public void unprogress()
|
public void unprogress()
|
||||||
{
|
{
|
||||||
if (Preferences.getBoolean("editor.beep.compile")) {
|
if (PreferencesData.getBoolean("editor.beep.compile")) {
|
||||||
Toolkit.getDefaultToolkit().beep();
|
Toolkit.getDefaultToolkit().beep();
|
||||||
}
|
}
|
||||||
if (progressBar == null) return;
|
if (progressBar == null) return;
|
||||||
@ -467,7 +467,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
|
|||||||
message += _("Arduino: ") + BaseNoGui.VERSION_NAME + " (" + System.getProperty("os.name") + "), ";
|
message += _("Arduino: ") + BaseNoGui.VERSION_NAME + " (" + System.getProperty("os.name") + "), ";
|
||||||
message += _("Board: ") + "\"" + Base.getBoardPreferences().get("name") + "\"\n\n";
|
message += _("Board: ") + "\"" + Base.getBoardPreferences().get("name") + "\"\n\n";
|
||||||
message += editor.console.consoleTextPane.getText().trim();
|
message += editor.console.consoleTextPane.getText().trim();
|
||||||
if ((Preferences.getBoolean("build.verbose")) == false) {
|
if ((PreferencesData.getBoolean("build.verbose")) == false) {
|
||||||
message += "\n\n";
|
message += "\n\n";
|
||||||
message += " " + _("This report would have more information with") + "\n";
|
message += " " + _("This report would have more information with") + "\n";
|
||||||
message += " \"" + _("Show verbose output during compilation") + "\"\n";
|
message += " \"" + _("Show verbose output during compilation") + "\"\n";
|
||||||
|
@ -24,7 +24,6 @@ package processing.app;
|
|||||||
import processing.app.helpers.FileUtils;
|
import processing.app.helpers.FileUtils;
|
||||||
import processing.app.helpers.OSUtils;
|
import processing.app.helpers.OSUtils;
|
||||||
import processing.app.helpers.PreferencesHelper;
|
import processing.app.helpers.PreferencesHelper;
|
||||||
import processing.app.helpers.PreferencesMap;
|
|
||||||
import processing.app.legacy.PApplet;
|
import processing.app.legacy.PApplet;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@ -353,7 +352,7 @@ public class Preferences {
|
|||||||
pane.add(box);
|
pane.add(box);
|
||||||
d = box.getPreferredSize();
|
d = box.getPreferredSize();
|
||||||
box.setBounds(left, top, d.width, d.height);
|
box.setBounds(left, top, d.width, d.height);
|
||||||
Font editorFont = Preferences.getFont("editor.font");
|
Font editorFont = PreferencesData.getFont("editor.font");
|
||||||
fontSizeField.setText(String.valueOf(editorFont.getSize()));
|
fontSizeField.setText(String.valueOf(editorFont.getSize()));
|
||||||
top += d.height + GUI_BETWEEN;
|
top += d.height + GUI_BETWEEN;
|
||||||
|
|
||||||
@ -786,22 +785,22 @@ public class Preferences {
|
|||||||
WarningItem warningItem = (WarningItem) comboWarnings.getSelectedItem();
|
WarningItem warningItem = (WarningItem) comboWarnings.getSelectedItem();
|
||||||
PreferencesData.set("compiler.warning_level", warningItem.getValue());
|
PreferencesData.set("compiler.warning_level", warningItem.getValue());
|
||||||
|
|
||||||
Preferences.set("proxy.http.server", proxyHTTPServer.getText());
|
PreferencesData.set("proxy.http.server", proxyHTTPServer.getText());
|
||||||
try {
|
try {
|
||||||
Preferences.set("proxy.http.port", Integer.valueOf(proxyHTTPPort.getText()).toString());
|
PreferencesData.set("proxy.http.port", Integer.valueOf(proxyHTTPPort.getText()).toString());
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
Preferences.remove("proxy.http.port");
|
PreferencesData.remove("proxy.http.port");
|
||||||
}
|
}
|
||||||
Preferences.set("proxy.https.server", proxyHTTPSServer.getText());
|
PreferencesData.set("proxy.https.server", proxyHTTPSServer.getText());
|
||||||
try {
|
try {
|
||||||
Preferences.set("proxy.https.port", Integer.valueOf(proxyHTTPSPort.getText()).toString());
|
PreferencesData.set("proxy.https.port", Integer.valueOf(proxyHTTPSPort.getText()).toString());
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
Preferences.remove("proxy.https.port");
|
PreferencesData.remove("proxy.https.port");
|
||||||
}
|
}
|
||||||
Preferences.set("proxy.user", proxyUser.getText());
|
PreferencesData.set("proxy.user", proxyUser.getText());
|
||||||
Preferences.set("proxy.password", new String(proxyPassword.getPassword()));
|
PreferencesData.set("proxy.password", new String(proxyPassword.getPassword()));
|
||||||
|
|
||||||
Preferences.set("boardsmanager.additional.urls", additionalBoardsManagerField.getText().replace("\r\n", "\n").replace("\r", "\n").replace("\n", ","));
|
PreferencesData.set("boardsmanager.additional.urls", additionalBoardsManagerField.getText().replace("\r\n", "\n").replace("\r", "\n").replace("\n", ","));
|
||||||
|
|
||||||
editor.applyPreferences();
|
editor.applyPreferences();
|
||||||
}
|
}
|
||||||
@ -834,22 +833,22 @@ public class Preferences {
|
|||||||
|
|
||||||
updateExtensionBox.setSelected(PreferencesData.get("editor.update_extension") == null || PreferencesData.getBoolean("editor.update_extension"));
|
updateExtensionBox.setSelected(PreferencesData.get("editor.update_extension") == null || PreferencesData.getBoolean("editor.update_extension"));
|
||||||
|
|
||||||
proxyHTTPServer.setText(Preferences.get("proxy.http.server"));
|
proxyHTTPServer.setText(PreferencesData.get("proxy.http.server"));
|
||||||
try {
|
try {
|
||||||
proxyHTTPPort.setText(Integer.toString(Preferences.getInteger("proxy.http.port", 8080)));
|
proxyHTTPPort.setText(Integer.toString(PreferencesData.getInteger("proxy.http.port", 8080)));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
proxyHTTPPort.setText("");
|
proxyHTTPPort.setText("");
|
||||||
}
|
}
|
||||||
proxyHTTPSServer.setText(Preferences.get("proxy.https.server"));
|
proxyHTTPSServer.setText(PreferencesData.get("proxy.https.server"));
|
||||||
try {
|
try {
|
||||||
proxyHTTPSPort.setText(Integer.toString(Preferences.getInteger("proxy.https.port", 8443)));
|
proxyHTTPSPort.setText(Integer.toString(PreferencesData.getInteger("proxy.https.port", 8443)));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
proxyHTTPSPort.setText("");
|
proxyHTTPSPort.setText("");
|
||||||
}
|
}
|
||||||
proxyUser.setText(Preferences.get("proxy.user"));
|
proxyUser.setText(PreferencesData.get("proxy.user"));
|
||||||
proxyPassword.setText(Preferences.get("proxy.password"));
|
proxyPassword.setText(PreferencesData.get("proxy.password"));
|
||||||
|
|
||||||
additionalBoardsManagerField.setText(Preferences.get("boardsmanager.additional.urls"));
|
additionalBoardsManagerField.setText(PreferencesData.get("boardsmanager.additional.urls"));
|
||||||
|
|
||||||
dialog.setLocationRelativeTo(editor);
|
dialog.setLocationRelativeTo(editor);
|
||||||
dialog.setVisible(true);
|
dialog.setVisible(true);
|
||||||
@ -863,76 +862,4 @@ public class Preferences {
|
|||||||
|
|
||||||
// .................................................................
|
// .................................................................
|
||||||
|
|
||||||
static public String get(String attribute) {
|
|
||||||
return PreferencesData.get(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
static public String get(String attribute, String defaultValue) {
|
|
||||||
return PreferencesData.get(attribute, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean has(String key) {
|
|
||||||
return PreferencesData.has(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void remove(String key) {
|
|
||||||
PreferencesData.remove(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static public void set(String attribute, String value) {
|
|
||||||
PreferencesData.set(attribute, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static public boolean getBoolean(String attribute) {
|
|
||||||
return PreferencesData.getBoolean(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static public void setBoolean(String attribute, boolean value) {
|
|
||||||
PreferencesData.setBoolean(attribute, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static public int getInteger(String attribute) {
|
|
||||||
return PreferencesData.getInteger(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
static public int getInteger(String attribute, int defaultValue) {
|
|
||||||
if (PreferencesData.has(attribute)) {
|
|
||||||
return PreferencesData.getInteger(attribute);
|
|
||||||
}
|
|
||||||
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static public void setInteger(String key, int value) {
|
|
||||||
PreferencesData.setInteger(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static public Font getFont(String attr) {
|
|
||||||
Font font = PreferencesHelper.getFont(PreferencesData.prefs, attr);
|
|
||||||
if (font == null) {
|
|
||||||
String value = PreferencesData.defaults.get(attr);
|
|
||||||
PreferencesData.prefs.put(attr, value);
|
|
||||||
font = PreferencesHelper.getFont(PreferencesData.prefs, attr);
|
|
||||||
}
|
|
||||||
return font;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get a copy of the Preferences
|
|
||||||
static public PreferencesMap getMap()
|
|
||||||
{
|
|
||||||
return PreferencesData.getMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decide wether changed preferences will be saved. When value is
|
|
||||||
// false, Preferences.save becomes a no-op.
|
|
||||||
static public void setDoSave(boolean value)
|
|
||||||
{
|
|
||||||
PreferencesData.setDoSave(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -74,14 +74,14 @@ public class PresentMode {
|
|||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
int index = selector.getSelectedIndex();
|
int index = selector.getSelectedIndex();
|
||||||
//device = devices[index];
|
//device = devices[index];
|
||||||
Preferences.setInteger("run.present.display", index + 1);
|
PreferencesData.setInteger("run.present.display", index + 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static public JComboBox getSelector() {
|
static public JComboBox getSelector() {
|
||||||
int deviceIndex = Preferences.getInteger("run.present.display") - 1;
|
int deviceIndex = PreferencesData.getInteger("run.present.display") - 1;
|
||||||
selector.setSelectedIndex(deviceIndex);
|
selector.setSelectedIndex(deviceIndex);
|
||||||
return selector;
|
return selector;
|
||||||
}
|
}
|
||||||
|
@ -39,14 +39,14 @@ public class SerialMonitor extends AbstractMonitor {
|
|||||||
|
|
||||||
this.port = port.getAddress();
|
this.port = port.getAddress();
|
||||||
|
|
||||||
serialRate = Preferences.getInteger("serial.debug_rate");
|
serialRate = PreferencesData.getInteger("serial.debug_rate");
|
||||||
serialRates.setSelectedItem(serialRate + " " + _("baud"));
|
serialRates.setSelectedItem(serialRate + " " + _("baud"));
|
||||||
onSerialRateChange(new ActionListener() {
|
onSerialRateChange(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
String wholeString = (String) serialRates.getSelectedItem();
|
String wholeString = (String) serialRates.getSelectedItem();
|
||||||
String rateString = wholeString.substring(0, wholeString.indexOf(' '));
|
String rateString = wholeString.substring(0, wholeString.indexOf(' '));
|
||||||
serialRate = Integer.parseInt(rateString);
|
serialRate = Integer.parseInt(rateString);
|
||||||
Preferences.set("serial.debug_rate", rateString);
|
PreferencesData.set("serial.debug_rate", rateString);
|
||||||
try {
|
try {
|
||||||
close();
|
close();
|
||||||
Thread.sleep(100); // Wait for serial port to properly close
|
Thread.sleep(100); // Wait for serial port to properly close
|
||||||
@ -80,9 +80,9 @@ public class SerialMonitor extends AbstractMonitor {
|
|||||||
s += "\r\n";
|
s += "\r\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ("".equals(s) && lineEndings.getSelectedIndex() == 0 && !Preferences.has("runtime.line.ending.alert.notified")) {
|
if ("".equals(s) && lineEndings.getSelectedIndex() == 0 && !PreferencesData.has("runtime.line.ending.alert.notified")) {
|
||||||
noLineEndingAlert.setForeground(Color.RED);
|
noLineEndingAlert.setForeground(Color.RED);
|
||||||
Preferences.set("runtime.line.ending.alert.notified", "true");
|
PreferencesData.set("runtime.line.ending.alert.notified", "true");
|
||||||
}
|
}
|
||||||
serial.write(s);
|
serial.write(s);
|
||||||
}
|
}
|
||||||
@ -103,7 +103,7 @@ public class SerialMonitor extends AbstractMonitor {
|
|||||||
if (serial != null) {
|
if (serial != null) {
|
||||||
int[] location = getPlacement();
|
int[] location = getPlacement();
|
||||||
String locationStr = PApplet.join(PApplet.str(location), ",");
|
String locationStr = PApplet.join(PApplet.str(location), ",");
|
||||||
Preferences.set("last.serial.location", locationStr);
|
PreferencesData.set("last.serial.location", locationStr);
|
||||||
textArea.setText("");
|
textArea.setText("");
|
||||||
serial.dispose();
|
serial.dispose();
|
||||||
serial = null;
|
serial = null;
|
||||||
|
@ -575,7 +575,7 @@ public class Sketch {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (pdeFiles != null && pdeFiles.length > 0) {
|
if (pdeFiles != null && pdeFiles.length > 0) {
|
||||||
if (Preferences.get("editor.update_extension") == null) {
|
if (PreferencesData.get("editor.update_extension") == null) {
|
||||||
Object[] options = { _("OK"), _("Cancel") };
|
Object[] options = { _("OK"), _("Cancel") };
|
||||||
int result = JOptionPane.showOptionDialog(editor,
|
int result = JOptionPane.showOptionDialog(editor,
|
||||||
_("In Arduino 1.0, the default file extension has changed\n" +
|
_("In Arduino 1.0, the default file extension has changed\n" +
|
||||||
@ -594,10 +594,10 @@ public class Sketch {
|
|||||||
|
|
||||||
if (result != JOptionPane.OK_OPTION) return false; // save cancelled
|
if (result != JOptionPane.OK_OPTION) return false; // save cancelled
|
||||||
|
|
||||||
Preferences.setBoolean("editor.update_extension", true);
|
PreferencesData.setBoolean("editor.update_extension", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Preferences.getBoolean("editor.update_extension")) {
|
if (PreferencesData.getBoolean("editor.update_extension")) {
|
||||||
// Do rename of all .pde files to new .ino extension
|
// Do rename of all .pde files to new .ino extension
|
||||||
for (File pdeFile : pdeFiles)
|
for (File pdeFile : pdeFiles)
|
||||||
renameCodeToInoExtension(pdeFile);
|
renameCodeToInoExtension(pdeFile);
|
||||||
@ -801,7 +801,7 @@ public class Sketch {
|
|||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
editor.statusNotice(_("One file added to the sketch."));
|
editor.statusNotice(_("One file added to the sketch."));
|
||||||
Preferences.set("last.folder", sourceFile.getAbsolutePath());
|
PreferencesData.set("last.folder", sourceFile.getAbsolutePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1059,7 +1059,7 @@ public class Sketch {
|
|||||||
|
|
||||||
// if an external editor is being used, need to grab the
|
// if an external editor is being used, need to grab the
|
||||||
// latest version of the code from the file.
|
// latest version of the code from the file.
|
||||||
if (Preferences.getBoolean("editor.external")) {
|
if (PreferencesData.getBoolean("editor.external")) {
|
||||||
// history gets screwed by the open..
|
// history gets screwed by the open..
|
||||||
//String historySaved = history.lastRecorded;
|
//String historySaved = history.lastRecorded;
|
||||||
//handleOpen(sketch);
|
//handleOpen(sketch);
|
||||||
@ -1202,7 +1202,7 @@ public class Sketch {
|
|||||||
|
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
do {
|
do {
|
||||||
if (uploader.requiresAuthorization() && !Preferences.has(uploader.getAuthorizationKey())) {
|
if (uploader.requiresAuthorization() && !PreferencesData.has(uploader.getAuthorizationKey())) {
|
||||||
PasswordAuthorizationDialog dialog = new PasswordAuthorizationDialog(editor, _("Type board password to upload a new sketch"));
|
PasswordAuthorizationDialog dialog = new PasswordAuthorizationDialog(editor, _("Type board password to upload a new sketch"));
|
||||||
dialog.setLocationRelativeTo(editor);
|
dialog.setLocationRelativeTo(editor);
|
||||||
dialog.setVisible(true);
|
dialog.setVisible(true);
|
||||||
@ -1212,7 +1212,7 @@ public class Sketch {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Preferences.set(uploader.getAuthorizationKey(), dialog.getPassword());
|
PreferencesData.set(uploader.getAuthorizationKey(), dialog.getPassword());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> warningsAccumulator = new LinkedList<String>();
|
List<String> warningsAccumulator = new LinkedList<String>();
|
||||||
@ -1220,7 +1220,7 @@ public class Sketch {
|
|||||||
success = Compiler.upload(data, uploader, buildPath, suggestedClassName, usingProgrammer, false, warningsAccumulator);
|
success = Compiler.upload(data, uploader, buildPath, suggestedClassName, usingProgrammer, false, warningsAccumulator);
|
||||||
} finally {
|
} finally {
|
||||||
if (uploader.requiresAuthorization() && !success) {
|
if (uploader.requiresAuthorization() && !success) {
|
||||||
Preferences.remove(uploader.getAuthorizationKey());
|
PreferencesData.remove(uploader.getAuthorizationKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,11 +69,11 @@ public class UpdateCheck implements Runnable {
|
|||||||
Random r = new Random();
|
Random r = new Random();
|
||||||
long id = r.nextLong();
|
long id = r.nextLong();
|
||||||
|
|
||||||
String idString = Preferences.get("update.id");
|
String idString = PreferencesData.get("update.id");
|
||||||
if (idString != null) {
|
if (idString != null) {
|
||||||
id = Long.parseLong(idString);
|
id = Long.parseLong(idString);
|
||||||
} else {
|
} else {
|
||||||
Preferences.set("update.id", String.valueOf(id));
|
PreferencesData.set("update.id", String.valueOf(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -88,7 +88,7 @@ public class UpdateCheck implements Runnable {
|
|||||||
|
|
||||||
int latest = readInt(downloadURL + "?" + info);
|
int latest = readInt(downloadURL + "?" + info);
|
||||||
|
|
||||||
String lastString = Preferences.get("update.last");
|
String lastString = PreferencesData.get("update.last");
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
if (lastString != null) {
|
if (lastString != null) {
|
||||||
long when = Long.parseLong(lastString);
|
long when = Long.parseLong(lastString);
|
||||||
@ -97,7 +97,7 @@ public class UpdateCheck implements Runnable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Preferences.set("update.last", String.valueOf(now));
|
PreferencesData.set("update.last", String.valueOf(now));
|
||||||
|
|
||||||
String prompt =
|
String prompt =
|
||||||
_("A new version of Arduino is available,\n" +
|
_("A new version of Arduino is available,\n" +
|
||||||
|
@ -44,7 +44,7 @@ public class PdeTextAreaDefaults extends TextAreaDefaults {
|
|||||||
inputHandler.addKeyBinding("BACK_SPACE", InputHandler.BACKSPACE);
|
inputHandler.addKeyBinding("BACK_SPACE", InputHandler.BACKSPACE);
|
||||||
// for 0122, shift-backspace is delete, for 0176, it's now a preference,
|
// for 0122, shift-backspace is delete, for 0176, it's now a preference,
|
||||||
// to prevent holy warriors from attacking me for it.
|
// to prevent holy warriors from attacking me for it.
|
||||||
if (Preferences.getBoolean("editor.keys.shift_backspace_is_delete")) {
|
if (PreferencesData.getBoolean("editor.keys.shift_backspace_is_delete")) {
|
||||||
inputHandler.addKeyBinding("S+BACK_SPACE", InputHandler.DELETE);
|
inputHandler.addKeyBinding("S+BACK_SPACE", InputHandler.DELETE);
|
||||||
} else {
|
} else {
|
||||||
inputHandler.addKeyBinding("S+BACK_SPACE", InputHandler.BACKSPACE);
|
inputHandler.addKeyBinding("S+BACK_SPACE", InputHandler.BACKSPACE);
|
||||||
@ -65,7 +65,7 @@ public class PdeTextAreaDefaults extends TextAreaDefaults {
|
|||||||
|
|
||||||
// http://dev.processing.org/bugs/show_bug.cgi?id=162
|
// http://dev.processing.org/bugs/show_bug.cgi?id=162
|
||||||
// added for 0176, though the bindings do not appear relevant for osx
|
// added for 0176, though the bindings do not appear relevant for osx
|
||||||
if (Preferences.getBoolean("editor.keys.alternative_cut_copy_paste")) {
|
if (PreferencesData.getBoolean("editor.keys.alternative_cut_copy_paste")) {
|
||||||
inputHandler.addKeyBinding("C+INSERT", InputHandler.CLIPBOARD_COPY);
|
inputHandler.addKeyBinding("C+INSERT", InputHandler.CLIPBOARD_COPY);
|
||||||
inputHandler.addKeyBinding("S+INSERT", InputHandler.CLIPBOARD_PASTE);
|
inputHandler.addKeyBinding("S+INSERT", InputHandler.CLIPBOARD_PASTE);
|
||||||
inputHandler.addKeyBinding("S+DELETE", InputHandler.CLIPBOARD_CUT);
|
inputHandler.addKeyBinding("S+DELETE", InputHandler.CLIPBOARD_CUT);
|
||||||
@ -78,7 +78,7 @@ public class PdeTextAreaDefaults extends TextAreaDefaults {
|
|||||||
// HOME and END now mean the beginning/end of the document
|
// HOME and END now mean the beginning/end of the document
|
||||||
// for 0176 changed this to a preference so that the Mac OS X people
|
// for 0176 changed this to a preference so that the Mac OS X people
|
||||||
// can get the "normal" behavior as well if they prefer.
|
// can get the "normal" behavior as well if they prefer.
|
||||||
if (Preferences.getBoolean("editor.keys.home_and_end_travel_far")) {
|
if (PreferencesData.getBoolean("editor.keys.home_and_end_travel_far")) {
|
||||||
inputHandler.addKeyBinding("HOME", InputHandler.DOCUMENT_HOME);
|
inputHandler.addKeyBinding("HOME", InputHandler.DOCUMENT_HOME);
|
||||||
inputHandler.addKeyBinding("END", InputHandler.DOCUMENT_END);
|
inputHandler.addKeyBinding("END", InputHandler.DOCUMENT_END);
|
||||||
inputHandler.addKeyBinding("S+HOME", InputHandler.SELECT_DOC_HOME);
|
inputHandler.addKeyBinding("S+HOME", InputHandler.SELECT_DOC_HOME);
|
||||||
@ -182,13 +182,13 @@ public class PdeTextAreaDefaults extends TextAreaDefaults {
|
|||||||
|
|
||||||
// moved from TextAreaPainter
|
// moved from TextAreaPainter
|
||||||
|
|
||||||
font = Preferences.getFont("editor.font");
|
font = PreferencesData.getFont("editor.font");
|
||||||
|
|
||||||
fgcolor = Theme.getColor("editor.fgcolor");
|
fgcolor = Theme.getColor("editor.fgcolor");
|
||||||
bgcolor = Theme.getColor("editor.bgcolor");
|
bgcolor = Theme.getColor("editor.bgcolor");
|
||||||
|
|
||||||
caretVisible = true;
|
caretVisible = true;
|
||||||
caretBlinks = Preferences.getBoolean("editor.caret.blink");
|
caretBlinks = PreferencesData.getBoolean("editor.caret.blink");
|
||||||
caretColor = Theme.getColor("editor.caret.color");
|
caretColor = Theme.getColor("editor.caret.color");
|
||||||
|
|
||||||
selectionColor = Theme.getColor("editor.selection.color");
|
selectionColor = Theme.getColor("editor.selection.color");
|
||||||
|
@ -60,7 +60,7 @@ implements TabExpander, Printable
|
|||||||
setForeground(defaults.fgcolor);
|
setForeground(defaults.fgcolor);
|
||||||
setBackground(defaults.bgcolor);
|
setBackground(defaults.bgcolor);
|
||||||
|
|
||||||
antialias = Preferences.getBoolean("editor.antialias");
|
antialias = PreferencesData.getBoolean("editor.antialias");
|
||||||
|
|
||||||
blockCaret = defaults.blockCaret;
|
blockCaret = defaults.blockCaret;
|
||||||
styles = defaults.styles;
|
styles = defaults.styles;
|
||||||
|
@ -440,7 +440,7 @@ public class AutoFormat implements Tool {
|
|||||||
// Adding an additional newline as a hack around other errors
|
// Adding an additional newline as a hack around other errors
|
||||||
String originalText = editor.getText() + "\n";
|
String originalText = editor.getText() + "\n";
|
||||||
strOut = new StringBuffer();
|
strOut = new StringBuffer();
|
||||||
indentValue = Preferences.getInteger("editor.tabs.size");
|
indentValue = PreferencesData.getInteger("editor.tabs.size");
|
||||||
indentChar = new String(" ");
|
indentChar = new String(" ");
|
||||||
|
|
||||||
lineNumber = 0;
|
lineNumber = 0;
|
||||||
|
@ -43,18 +43,18 @@ public class DefaultTargetTest extends AbstractWithPreferencesTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void saveBoardFromPreferences() throws Exception {
|
public void saveBoardFromPreferences() throws Exception {
|
||||||
oldBoardID = Preferences.get("board");
|
oldBoardID = PreferencesData.get("board");
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void restoreBoardIntoPreferences() throws Exception {
|
public void restoreBoardIntoPreferences() throws Exception {
|
||||||
Preferences.set("board", oldBoardID);
|
PreferencesData.set("board", oldBoardID);
|
||||||
Preferences.save();
|
PreferencesData.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDefaultTarget() throws Exception {
|
public void testDefaultTarget() throws Exception {
|
||||||
Preferences.set("board", "unreal_board");
|
PreferencesData.set("board", "unreal_board");
|
||||||
|
|
||||||
// should not raise an exception
|
// should not raise an exception
|
||||||
new Base(new String[0]);
|
new Base(new String[0]);
|
||||||
|
@ -2,6 +2,7 @@ package processing.app;
|
|||||||
|
|
||||||
import static processing.app.I18n._;
|
import static processing.app.I18n._;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -12,6 +13,7 @@ import java.util.Arrays;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.MissingResourceException;
|
import java.util.MissingResourceException;
|
||||||
|
|
||||||
|
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;
|
||||||
import processing.app.legacy.PConstants;
|
import processing.app.legacy.PConstants;
|
||||||
@ -179,6 +181,13 @@ public class PreferencesData {
|
|||||||
return Integer.parseInt(get(attribute));
|
return Integer.parseInt(get(attribute));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public int getInteger(String attribute, int defaultValue) {
|
||||||
|
if (has(attribute)) {
|
||||||
|
return getInteger(attribute);
|
||||||
|
}
|
||||||
|
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
static public void setInteger(String key, int value) {
|
static public void setInteger(String key, int value) {
|
||||||
set(key, String.valueOf(value));
|
set(key, String.valueOf(value));
|
||||||
@ -203,4 +212,14 @@ public class PreferencesData {
|
|||||||
{
|
{
|
||||||
doSave = value;
|
doSave = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public Font getFont(String attr) {
|
||||||
|
Font font = PreferencesHelper.getFont(prefs, attr);
|
||||||
|
if (font == null) {
|
||||||
|
String value = defaults.get(attr);
|
||||||
|
prefs.put(attr, value);
|
||||||
|
font = PreferencesHelper.getFont(prefs, attr);
|
||||||
|
}
|
||||||
|
return font;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user