Removed dependency from Preferences in a bunch of classes.

This commit is contained in:
Claudio Indellicati 2014-08-22 12:47:43 +02:00 committed by Cristian Maglie
parent 22be22a5a7
commit f2d92bbd0f
8 changed files with 50 additions and 50 deletions

View File

@ -25,7 +25,7 @@
package cc.arduino.packages; package cc.arduino.packages;
import processing.app.I18n; import processing.app.I18n;
import processing.app.Preferences; import processing.app.PreferencesData;
import processing.app.debug.MessageConsumer; import processing.app.debug.MessageConsumer;
import processing.app.debug.MessageSiphon; import processing.app.debug.MessageSiphon;
import processing.app.debug.RunnerException; import processing.app.debug.RunnerException;
@ -67,7 +67,7 @@ public abstract class Uploader implements MessageConsumer {
protected Uploader() { protected Uploader() {
this.error = null; this.error = null;
this.verbose = Preferences.getBoolean("upload.verbose"); this.verbose = PreferencesData.getBoolean("upload.verbose");
this.notFoundError = false; this.notFoundError = false;
} }

View File

@ -4,7 +4,7 @@ import cc.arduino.packages.BoardPort;
import com.jcraft.jsch.JSch; import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException; import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session; import com.jcraft.jsch.Session;
import processing.app.Preferences; import processing.app.PreferencesData;
public class SSHPwdSetup implements SSHClientSetupChainRing { public class SSHPwdSetup implements SSHClientSetupChainRing {
@ -13,7 +13,7 @@ public class SSHPwdSetup implements SSHClientSetupChainRing {
String ipAddress = port.getAddress(); String ipAddress = port.getAddress();
Session session = jSch.getSession("root", ipAddress, 22); Session session = jSch.getSession("root", ipAddress, 22);
session.setPassword(Preferences.get("runtime.pwd." + ipAddress)); session.setPassword(PreferencesData.get("runtime.pwd." + ipAddress));
return session; return session;
} }

View File

@ -37,7 +37,7 @@ import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session; import com.jcraft.jsch.Session;
import processing.app.BaseNoGui; import processing.app.BaseNoGui;
import processing.app.I18n; import processing.app.I18n;
import processing.app.Preferences; import processing.app.PreferencesData;
import processing.app.debug.RunnerException; import processing.app.debug.RunnerException;
import processing.app.debug.TargetPlatform; import processing.app.debug.TargetPlatform;
import processing.app.helpers.PreferencesMap; import processing.app.helpers.PreferencesMap;
@ -82,7 +82,7 @@ public class SSHUploader extends Uploader {
SSHClientSetupChainRing sshClientSetupChain = new SSHConfigFileSetup(new SSHPwdSetup()); SSHClientSetupChainRing sshClientSetupChain = new SSHConfigFileSetup(new SSHPwdSetup());
session = sshClientSetupChain.setup(port, jSch); session = sshClientSetupChain.setup(port, jSch);
session.setUserInfo(new NoInteractionUserInfo(Preferences.get("runtime.pwd." + port.getAddress()))); session.setUserInfo(new NoInteractionUserInfo(PreferencesData.get("runtime.pwd." + port.getAddress())));
session.connect(30000); session.connect(30000);
scp = new SCP(session); scp = new SCP(session);
@ -118,7 +118,7 @@ public class SSHUploader extends Uploader {
private boolean runAVRDude(SSH ssh) throws IOException, JSchException { private boolean runAVRDude(SSH ssh) throws IOException, JSchException {
TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform(); TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
PreferencesMap prefs = Preferences.getMap(); PreferencesMap prefs = PreferencesData.getMap();
prefs.putAll(BaseNoGui.getBoardPreferences()); prefs.putAll(BaseNoGui.getBoardPreferences());
prefs.putAll(targetPlatform.getTool(prefs.get("upload.tool"))); prefs.putAll(targetPlatform.getTool(prefs.get("upload.tool")));

View File

@ -34,7 +34,7 @@ import java.util.List;
import processing.app.BaseNoGui; import processing.app.BaseNoGui;
import processing.app.I18n; import processing.app.I18n;
import processing.app.Preferences; import processing.app.PreferencesData;
import processing.app.Serial; import processing.app.Serial;
import processing.app.SerialException; import processing.app.SerialException;
import processing.app.debug.RunnerException; import processing.app.debug.RunnerException;
@ -49,7 +49,7 @@ public class SerialUploader extends Uploader {
public boolean uploadUsingPreferences(File sourcePath, String buildPath, String className, boolean usingProgrammer, List<String> warningsAccumulator) throws Exception { public boolean uploadUsingPreferences(File sourcePath, String buildPath, String className, boolean usingProgrammer, List<String> warningsAccumulator) throws Exception {
// FIXME: Preferences should be reorganized // FIXME: Preferences should be reorganized
TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform(); TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
PreferencesMap prefs = Preferences.getMap(); PreferencesMap prefs = PreferencesData.getMap();
prefs.putAll(BaseNoGui.getBoardPreferences()); prefs.putAll(BaseNoGui.getBoardPreferences());
String tool = prefs.getOrExcept("upload.tool"); String tool = prefs.getOrExcept("upload.tool");
if (tool.contains(":")) { if (tool.contains(":")) {
@ -132,7 +132,7 @@ public class SerialUploader extends Uploader {
try { try {
if (uploadResult && doTouch) { if (uploadResult && doTouch) {
String uploadPort = Preferences.get("serial.port"); String uploadPort = PreferencesData.get("serial.port");
if (waitForUploadPort) { if (waitForUploadPort) {
// For Due/Leonardo wait until the bootloader serial port disconnects and the // For Due/Leonardo wait until the bootloader serial port disconnects and the
// sketch serial port reconnects (or timeout after a few seconds if the // sketch serial port reconnects (or timeout after a few seconds if the
@ -203,14 +203,14 @@ public class SerialUploader extends Uploader {
public boolean uploadUsingProgrammer(String buildPath, String className) throws Exception { public boolean uploadUsingProgrammer(String buildPath, String className) throws Exception {
TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform(); TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
String programmer = Preferences.get("programmer"); String programmer = PreferencesData.get("programmer");
if (programmer.contains(":")) { if (programmer.contains(":")) {
String[] split = programmer.split(":", 2); String[] split = programmer.split(":", 2);
targetPlatform = BaseNoGui.getCurrentTargetPlatformFromPackage(split[0]); targetPlatform = BaseNoGui.getCurrentTargetPlatformFromPackage(split[0]);
programmer = split[1]; programmer = split[1];
} }
PreferencesMap prefs = Preferences.getMap(); PreferencesMap prefs = PreferencesData.getMap();
prefs.putAll(BaseNoGui.getBoardPreferences()); prefs.putAll(BaseNoGui.getBoardPreferences());
PreferencesMap programmerPrefs = targetPlatform.getProgrammer(programmer); PreferencesMap programmerPrefs = targetPlatform.getProgrammer(programmer);
if (programmerPrefs == null) if (programmerPrefs == null)
@ -249,7 +249,7 @@ public class SerialUploader extends Uploader {
// Find preferences for the selected programmer // Find preferences for the selected programmer
PreferencesMap programmerPrefs; PreferencesMap programmerPrefs;
String programmer = Preferences.get("programmer"); String programmer = PreferencesData.get("programmer");
if (programmer.contains(":")) { if (programmer.contains(":")) {
String[] split = programmer.split(":", 2); String[] split = programmer.split(":", 2);
TargetPlatform platform = BaseNoGui.getCurrentTargetPlatformFromPackage(split[0]); TargetPlatform platform = BaseNoGui.getCurrentTargetPlatformFromPackage(split[0]);
@ -263,7 +263,7 @@ public class SerialUploader extends Uploader {
_("Please select a programmer from Tools->Programmer menu")); _("Please select a programmer from Tools->Programmer menu"));
// Build configuration for the current programmer // Build configuration for the current programmer
PreferencesMap prefs = Preferences.getMap(); PreferencesMap prefs = PreferencesData.getMap();
prefs.putAll(BaseNoGui.getBoardPreferences()); prefs.putAll(BaseNoGui.getBoardPreferences());
prefs.putAll(programmerPrefs); prefs.putAll(programmerPrefs);

View File

@ -85,7 +85,7 @@ public class BaseNoGui {
PreferencesMap prefs = new PreferencesMap(board.getPreferences()); PreferencesMap prefs = new PreferencesMap(board.getPreferences());
for (String menuId : board.getMenuIds()) { for (String menuId : board.getMenuIds()) {
String entry = Preferences.get("custom_" + menuId); String entry = PreferencesData.get("custom_" + menuId);
if (board.hasMenu(menuId) && entry != null && if (board.hasMenu(menuId) && entry != null &&
entry.startsWith(board.getId())) { entry.startsWith(board.getId())) {
String selectionId = entry.substring(entry.indexOf("_") + 1); String selectionId = entry.substring(entry.indexOf("_") + 1);
@ -114,7 +114,7 @@ public class BaseNoGui {
} }
static public TargetPlatform getCurrentTargetPlatformFromPackage(String pack) { static public TargetPlatform getCurrentTargetPlatformFromPackage(String pack) {
return getTargetPlatform(pack, Preferences.get("target_platform")); return getTargetPlatform(pack, PreferencesData.get("target_platform"));
} }
static public File getHardwareFolder() { static public File getHardwareFolder() {
@ -164,7 +164,7 @@ public class BaseNoGui {
File settingsFolder = null; File settingsFolder = null;
String preferencesPath = Preferences.get("settings.path"); String preferencesPath = PreferencesData.get("settings.path");
if (preferencesPath != null) { if (preferencesPath != null) {
settingsFolder = absoluteFile(preferencesPath); settingsFolder = absoluteFile(preferencesPath);
@ -190,8 +190,8 @@ public class BaseNoGui {
static public File getSketchbookFolder() { static public File getSketchbookFolder() {
if (portableFolder != null) if (portableFolder != null)
return new File(portableFolder, Preferences.get("sketchbook.path")); return new File(portableFolder, PreferencesData.get("sketchbook.path"));
return absoluteFile(Preferences.get("sketchbook.path")); return absoluteFile(PreferencesData.get("sketchbook.path"));
} }
static public File getSketchbookHardwareFolder() { static public File getSketchbookHardwareFolder() {
@ -199,7 +199,7 @@ public class BaseNoGui {
} }
public static TargetBoard getTargetBoard() { public static TargetBoard getTargetBoard() {
String boardId = Preferences.get("board"); String boardId = PreferencesData.get("board");
return getTargetPlatform().getBoard(boardId); return getTargetPlatform().getBoard(boardId);
} }
@ -209,8 +209,8 @@ public class BaseNoGui {
* @return * @return
*/ */
static public TargetPlatform getTargetPlatform() { static public TargetPlatform getTargetPlatform() {
String packageName = Preferences.get("target_package"); String packageName = PreferencesData.get("target_package");
String platformName = Preferences.get("target_platform"); String platformName = PreferencesData.get("target_platform");
return getTargetPlatform(packageName, platformName); return getTargetPlatform(packageName, platformName);
} }
@ -303,8 +303,8 @@ public class BaseNoGui {
} }
// help 3rd party installers find the correct hardware path // help 3rd party installers find the correct hardware path
Preferences.set("last.ide." + VERSION_NAME + ".hardwarepath", getHardwarePath()); PreferencesData.set("last.ide." + VERSION_NAME + ".hardwarepath", getHardwarePath());
Preferences.set("last.ide." + VERSION_NAME + ".daterun", "" + (new Date()).getTime() / 1000); PreferencesData.set("last.ide." + VERSION_NAME + ".daterun", "" + (new Date()).getTime() / 1000);
} }
static protected void loadHardware(File folder) { static protected void loadHardware(File folder) {
@ -360,7 +360,7 @@ public class BaseNoGui {
} }
// run static initialization that grabs all the prefs // run static initialization that grabs all the prefs
Preferences.init(absoluteFile(preferencesFile)); PreferencesData.init(absoluteFile(preferencesFile));
} }
/** /**

View File

@ -68,7 +68,7 @@ public class NetworkMonitor extends AbstractMonitor {
SSHClientSetupChainRing sshClientSetupChain = new SSHConfigFileSetup(new SSHPwdSetup()); SSHClientSetupChainRing sshClientSetupChain = new SSHConfigFileSetup(new SSHPwdSetup());
session = sshClientSetupChain.setup(port, jSch); session = sshClientSetupChain.setup(port, jSch);
session.setUserInfo(new NoInteractionUserInfo(Preferences.get(getAuthorizationKey()))); session.setUserInfo(new NoInteractionUserInfo(PreferencesData.get(getAuthorizationKey())));
session.connect(30000); session.connect(30000);
tryConnect(); tryConnect();

View File

@ -110,7 +110,7 @@ public class Platform {
public void openURL(String url) throws Exception { public void openURL(String url) throws Exception {
String launcher = Preferences.get("launcher"); String launcher = PreferencesData.get("launcher");
if (launcher != null) { if (launcher != null) {
Runtime.getRuntime().exec(new String[] { launcher, url }); Runtime.getRuntime().exec(new String[] { launcher, url });
} else { } else {
@ -120,12 +120,12 @@ public class Platform {
public boolean openFolderAvailable() { public boolean openFolderAvailable() {
return Preferences.get("launcher") != null; return PreferencesData.get("launcher") != null;
} }
public void openFolder(File file) throws Exception { public void openFolder(File file) throws Exception {
String launcher = Preferences.get("launcher"); String launcher = PreferencesData.get("launcher");
if (launcher != null) { if (launcher != null) {
String folder = file.getAbsolutePath(); String folder = file.getAbsolutePath();
Runtime.getRuntime().exec(new String[] { launcher, folder }); Runtime.getRuntime().exec(new String[] { launcher, folder });

View File

@ -63,40 +63,40 @@ public class Serial implements SerialPortEventListener {
MessageConsumer consumer; MessageConsumer consumer;
public Serial(boolean monitor) throws SerialException { public Serial(boolean monitor) throws SerialException {
this(Preferences.get("serial.port"), this(PreferencesData.get("serial.port"),
Preferences.getInteger("serial.debug_rate"), PreferencesData.getInteger("serial.debug_rate"),
Preferences.get("serial.parity").charAt(0), PreferencesData.get("serial.parity").charAt(0),
Preferences.getInteger("serial.databits"), PreferencesData.getInteger("serial.databits"),
new Float(Preferences.get("serial.stopbits")).floatValue()); new Float(PreferencesData.get("serial.stopbits")).floatValue());
this.monitor = monitor; this.monitor = monitor;
} }
public Serial() throws SerialException { public Serial() throws SerialException {
this(Preferences.get("serial.port"), this(PreferencesData.get("serial.port"),
Preferences.getInteger("serial.debug_rate"), PreferencesData.getInteger("serial.debug_rate"),
Preferences.get("serial.parity").charAt(0), PreferencesData.get("serial.parity").charAt(0),
Preferences.getInteger("serial.databits"), PreferencesData.getInteger("serial.databits"),
new Float(Preferences.get("serial.stopbits")).floatValue()); new Float(PreferencesData.get("serial.stopbits")).floatValue());
} }
public Serial(int irate) throws SerialException { public Serial(int irate) throws SerialException {
this(Preferences.get("serial.port"), irate, this(PreferencesData.get("serial.port"), irate,
Preferences.get("serial.parity").charAt(0), PreferencesData.get("serial.parity").charAt(0),
Preferences.getInteger("serial.databits"), PreferencesData.getInteger("serial.databits"),
new Float(Preferences.get("serial.stopbits")).floatValue()); new Float(PreferencesData.get("serial.stopbits")).floatValue());
} }
public Serial(String iname, int irate) throws SerialException { public Serial(String iname, int irate) throws SerialException {
this(iname, irate, Preferences.get("serial.parity").charAt(0), this(iname, irate, PreferencesData.get("serial.parity").charAt(0),
Preferences.getInteger("serial.databits"), PreferencesData.getInteger("serial.databits"),
new Float(Preferences.get("serial.stopbits")).floatValue()); new Float(PreferencesData.get("serial.stopbits")).floatValue());
} }
public Serial(String iname) throws SerialException { public Serial(String iname) throws SerialException {
this(iname, Preferences.getInteger("serial.debug_rate"), this(iname, PreferencesData.getInteger("serial.debug_rate"),
Preferences.get("serial.parity").charAt(0), PreferencesData.get("serial.parity").charAt(0),
Preferences.getInteger("serial.databits"), PreferencesData.getInteger("serial.databits"),
new Float(Preferences.get("serial.stopbits")).floatValue()); new Float(PreferencesData.get("serial.stopbits")).floatValue());
} }
public static boolean touchPort(String iname, int irate) throws SerialException { public static boolean touchPort(String iname, int irate) throws SerialException {