Skip to content

Commit f2d92bb

Browse files
bitroncmaglie
authored andcommitted
Removed dependency from Preferences in a bunch of classes.
1 parent 22be22a commit f2d92bb

File tree

8 files changed

+50
-50
lines changed

8 files changed

+50
-50
lines changed

app/src/cc/arduino/packages/Uploader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
package cc.arduino.packages;
2626

2727
import processing.app.I18n;
28-
import processing.app.Preferences;
28+
import processing.app.PreferencesData;
2929
import processing.app.debug.MessageConsumer;
3030
import processing.app.debug.MessageSiphon;
3131
import processing.app.debug.RunnerException;
@@ -67,7 +67,7 @@ public abstract class Uploader implements MessageConsumer {
6767

6868
protected Uploader() {
6969
this.error = null;
70-
this.verbose = Preferences.getBoolean("upload.verbose");
70+
this.verbose = PreferencesData.getBoolean("upload.verbose");
7171
this.notFoundError = false;
7272
}
7373

app/src/cc/arduino/packages/ssh/SSHPwdSetup.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import com.jcraft.jsch.JSch;
55
import com.jcraft.jsch.JSchException;
66
import com.jcraft.jsch.Session;
7-
import processing.app.Preferences;
7+
import processing.app.PreferencesData;
88

99
public class SSHPwdSetup implements SSHClientSetupChainRing {
1010

@@ -13,7 +13,7 @@ public Session setup(BoardPort port, JSch jSch) throws JSchException {
1313
String ipAddress = port.getAddress();
1414

1515
Session session = jSch.getSession("root", ipAddress, 22);
16-
session.setPassword(Preferences.get("runtime.pwd." + ipAddress));
16+
session.setPassword(PreferencesData.get("runtime.pwd." + ipAddress));
1717

1818
return session;
1919
}

app/src/cc/arduino/packages/uploaders/SSHUploader.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import com.jcraft.jsch.Session;
3838
import processing.app.BaseNoGui;
3939
import processing.app.I18n;
40-
import processing.app.Preferences;
40+
import processing.app.PreferencesData;
4141
import processing.app.debug.RunnerException;
4242
import processing.app.debug.TargetPlatform;
4343
import processing.app.helpers.PreferencesMap;
@@ -82,7 +82,7 @@ public boolean uploadUsingPreferences(File sourcePath, String buildPath, String
8282
SSHClientSetupChainRing sshClientSetupChain = new SSHConfigFileSetup(new SSHPwdSetup());
8383
session = sshClientSetupChain.setup(port, jSch);
8484

85-
session.setUserInfo(new NoInteractionUserInfo(Preferences.get("runtime.pwd." + port.getAddress())));
85+
session.setUserInfo(new NoInteractionUserInfo(PreferencesData.get("runtime.pwd." + port.getAddress())));
8686
session.connect(30000);
8787

8888
scp = new SCP(session);
@@ -118,7 +118,7 @@ public boolean uploadUsingPreferences(File sourcePath, String buildPath, String
118118

119119
private boolean runAVRDude(SSH ssh) throws IOException, JSchException {
120120
TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
121-
PreferencesMap prefs = Preferences.getMap();
121+
PreferencesMap prefs = PreferencesData.getMap();
122122
prefs.putAll(BaseNoGui.getBoardPreferences());
123123
prefs.putAll(targetPlatform.getTool(prefs.get("upload.tool")));
124124

app/src/cc/arduino/packages/uploaders/SerialUploader.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
import processing.app.BaseNoGui;
3636
import processing.app.I18n;
37-
import processing.app.Preferences;
37+
import processing.app.PreferencesData;
3838
import processing.app.Serial;
3939
import processing.app.SerialException;
4040
import processing.app.debug.RunnerException;
@@ -49,7 +49,7 @@ public class SerialUploader extends Uploader {
4949
public boolean uploadUsingPreferences(File sourcePath, String buildPath, String className, boolean usingProgrammer, List<String> warningsAccumulator) throws Exception {
5050
// FIXME: Preferences should be reorganized
5151
TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
52-
PreferencesMap prefs = Preferences.getMap();
52+
PreferencesMap prefs = PreferencesData.getMap();
5353
prefs.putAll(BaseNoGui.getBoardPreferences());
5454
String tool = prefs.getOrExcept("upload.tool");
5555
if (tool.contains(":")) {
@@ -132,7 +132,7 @@ public boolean uploadUsingPreferences(File sourcePath, String buildPath, String
132132

133133
try {
134134
if (uploadResult && doTouch) {
135-
String uploadPort = Preferences.get("serial.port");
135+
String uploadPort = PreferencesData.get("serial.port");
136136
if (waitForUploadPort) {
137137
// For Due/Leonardo wait until the bootloader serial port disconnects and the
138138
// sketch serial port reconnects (or timeout after a few seconds if the
@@ -203,14 +203,14 @@ private String waitForUploadPort(String uploadPort, List<String> before) throws
203203
public boolean uploadUsingProgrammer(String buildPath, String className) throws Exception {
204204

205205
TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
206-
String programmer = Preferences.get("programmer");
206+
String programmer = PreferencesData.get("programmer");
207207
if (programmer.contains(":")) {
208208
String[] split = programmer.split(":", 2);
209209
targetPlatform = BaseNoGui.getCurrentTargetPlatformFromPackage(split[0]);
210210
programmer = split[1];
211211
}
212212

213-
PreferencesMap prefs = Preferences.getMap();
213+
PreferencesMap prefs = PreferencesData.getMap();
214214
prefs.putAll(BaseNoGui.getBoardPreferences());
215215
PreferencesMap programmerPrefs = targetPlatform.getProgrammer(programmer);
216216
if (programmerPrefs == null)
@@ -249,7 +249,7 @@ public boolean burnBootloader() throws Exception {
249249

250250
// Find preferences for the selected programmer
251251
PreferencesMap programmerPrefs;
252-
String programmer = Preferences.get("programmer");
252+
String programmer = PreferencesData.get("programmer");
253253
if (programmer.contains(":")) {
254254
String[] split = programmer.split(":", 2);
255255
TargetPlatform platform = BaseNoGui.getCurrentTargetPlatformFromPackage(split[0]);
@@ -263,7 +263,7 @@ public boolean burnBootloader() throws Exception {
263263
_("Please select a programmer from Tools->Programmer menu"));
264264

265265
// Build configuration for the current programmer
266-
PreferencesMap prefs = Preferences.getMap();
266+
PreferencesMap prefs = PreferencesData.getMap();
267267
prefs.putAll(BaseNoGui.getBoardPreferences());
268268
prefs.putAll(programmerPrefs);
269269

app/src/processing/app/BaseNoGui.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static public PreferencesMap getBoardPreferences() {
8585

8686
PreferencesMap prefs = new PreferencesMap(board.getPreferences());
8787
for (String menuId : board.getMenuIds()) {
88-
String entry = Preferences.get("custom_" + menuId);
88+
String entry = PreferencesData.get("custom_" + menuId);
8989
if (board.hasMenu(menuId) && entry != null &&
9090
entry.startsWith(board.getId())) {
9191
String selectionId = entry.substring(entry.indexOf("_") + 1);
@@ -114,7 +114,7 @@ static public File getContentFile(String name) {
114114
}
115115

116116
static public TargetPlatform getCurrentTargetPlatformFromPackage(String pack) {
117-
return getTargetPlatform(pack, Preferences.get("target_platform"));
117+
return getTargetPlatform(pack, PreferencesData.get("target_platform"));
118118
}
119119

120120
static public File getHardwareFolder() {
@@ -164,7 +164,7 @@ static public File getSettingsFolder() {
164164

165165
File settingsFolder = null;
166166

167-
String preferencesPath = Preferences.get("settings.path");
167+
String preferencesPath = PreferencesData.get("settings.path");
168168
if (preferencesPath != null) {
169169
settingsFolder = absoluteFile(preferencesPath);
170170

@@ -190,16 +190,16 @@ static public File getSettingsFolder() {
190190

191191
static public File getSketchbookFolder() {
192192
if (portableFolder != null)
193-
return new File(portableFolder, Preferences.get("sketchbook.path"));
194-
return absoluteFile(Preferences.get("sketchbook.path"));
193+
return new File(portableFolder, PreferencesData.get("sketchbook.path"));
194+
return absoluteFile(PreferencesData.get("sketchbook.path"));
195195
}
196196

197197
static public File getSketchbookHardwareFolder() {
198198
return new File(getSketchbookFolder(), "hardware");
199199
}
200200

201201
public static TargetBoard getTargetBoard() {
202-
String boardId = Preferences.get("board");
202+
String boardId = PreferencesData.get("board");
203203
return getTargetPlatform().getBoard(boardId);
204204
}
205205

@@ -209,8 +209,8 @@ public static TargetBoard getTargetBoard() {
209209
* @return
210210
*/
211211
static public TargetPlatform getTargetPlatform() {
212-
String packageName = Preferences.get("target_package");
213-
String platformName = Preferences.get("target_platform");
212+
String packageName = PreferencesData.get("target_package");
213+
String platformName = PreferencesData.get("target_platform");
214214
return getTargetPlatform(packageName, platformName);
215215
}
216216

@@ -303,8 +303,8 @@ static public void initVersion() {
303303
}
304304

305305
// help 3rd party installers find the correct hardware path
306-
Preferences.set("last.ide." + VERSION_NAME + ".hardwarepath", getHardwarePath());
307-
Preferences.set("last.ide." + VERSION_NAME + ".daterun", "" + (new Date()).getTime() / 1000);
306+
PreferencesData.set("last.ide." + VERSION_NAME + ".hardwarepath", getHardwarePath());
307+
PreferencesData.set("last.ide." + VERSION_NAME + ".daterun", "" + (new Date()).getTime() / 1000);
308308
}
309309

310310
static protected void loadHardware(File folder) {
@@ -360,7 +360,7 @@ static public void prescanParameters(String args[]) {
360360
}
361361

362362
// run static initialization that grabs all the prefs
363-
Preferences.init(absoluteFile(preferencesFile));
363+
PreferencesData.init(absoluteFile(preferencesFile));
364364
}
365365

366366
/**

app/src/processing/app/NetworkMonitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void open() throws Exception {
6868
SSHClientSetupChainRing sshClientSetupChain = new SSHConfigFileSetup(new SSHPwdSetup());
6969
session = sshClientSetupChain.setup(port, jSch);
7070

71-
session.setUserInfo(new NoInteractionUserInfo(Preferences.get(getAuthorizationKey())));
71+
session.setUserInfo(new NoInteractionUserInfo(PreferencesData.get(getAuthorizationKey())));
7272
session.connect(30000);
7373

7474
tryConnect();

app/src/processing/app/Platform.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public File getDefaultSketchbookFolder() throws Exception {
110110

111111

112112
public void openURL(String url) throws Exception {
113-
String launcher = Preferences.get("launcher");
113+
String launcher = PreferencesData.get("launcher");
114114
if (launcher != null) {
115115
Runtime.getRuntime().exec(new String[] { launcher, url });
116116
} else {
@@ -120,12 +120,12 @@ public void openURL(String url) throws Exception {
120120

121121

122122
public boolean openFolderAvailable() {
123-
return Preferences.get("launcher") != null;
123+
return PreferencesData.get("launcher") != null;
124124
}
125125

126126

127127
public void openFolder(File file) throws Exception {
128-
String launcher = Preferences.get("launcher");
128+
String launcher = PreferencesData.get("launcher");
129129
if (launcher != null) {
130130
String folder = file.getAbsolutePath();
131131
Runtime.getRuntime().exec(new String[] { launcher, folder });

app/src/processing/app/Serial.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -63,40 +63,40 @@ public class Serial implements SerialPortEventListener {
6363
MessageConsumer consumer;
6464

6565
public Serial(boolean monitor) throws SerialException {
66-
this(Preferences.get("serial.port"),
67-
Preferences.getInteger("serial.debug_rate"),
68-
Preferences.get("serial.parity").charAt(0),
69-
Preferences.getInteger("serial.databits"),
70-
new Float(Preferences.get("serial.stopbits")).floatValue());
66+
this(PreferencesData.get("serial.port"),
67+
PreferencesData.getInteger("serial.debug_rate"),
68+
PreferencesData.get("serial.parity").charAt(0),
69+
PreferencesData.getInteger("serial.databits"),
70+
new Float(PreferencesData.get("serial.stopbits")).floatValue());
7171
this.monitor = monitor;
7272
}
7373

7474
public Serial() throws SerialException {
75-
this(Preferences.get("serial.port"),
76-
Preferences.getInteger("serial.debug_rate"),
77-
Preferences.get("serial.parity").charAt(0),
78-
Preferences.getInteger("serial.databits"),
79-
new Float(Preferences.get("serial.stopbits")).floatValue());
75+
this(PreferencesData.get("serial.port"),
76+
PreferencesData.getInteger("serial.debug_rate"),
77+
PreferencesData.get("serial.parity").charAt(0),
78+
PreferencesData.getInteger("serial.databits"),
79+
new Float(PreferencesData.get("serial.stopbits")).floatValue());
8080
}
8181

8282
public Serial(int irate) throws SerialException {
83-
this(Preferences.get("serial.port"), irate,
84-
Preferences.get("serial.parity").charAt(0),
85-
Preferences.getInteger("serial.databits"),
86-
new Float(Preferences.get("serial.stopbits")).floatValue());
83+
this(PreferencesData.get("serial.port"), irate,
84+
PreferencesData.get("serial.parity").charAt(0),
85+
PreferencesData.getInteger("serial.databits"),
86+
new Float(PreferencesData.get("serial.stopbits")).floatValue());
8787
}
8888

8989
public Serial(String iname, int irate) throws SerialException {
90-
this(iname, irate, Preferences.get("serial.parity").charAt(0),
91-
Preferences.getInteger("serial.databits"),
92-
new Float(Preferences.get("serial.stopbits")).floatValue());
90+
this(iname, irate, PreferencesData.get("serial.parity").charAt(0),
91+
PreferencesData.getInteger("serial.databits"),
92+
new Float(PreferencesData.get("serial.stopbits")).floatValue());
9393
}
9494

9595
public Serial(String iname) throws SerialException {
96-
this(iname, Preferences.getInteger("serial.debug_rate"),
97-
Preferences.get("serial.parity").charAt(0),
98-
Preferences.getInteger("serial.databits"),
99-
new Float(Preferences.get("serial.stopbits")).floatValue());
96+
this(iname, PreferencesData.getInteger("serial.debug_rate"),
97+
PreferencesData.get("serial.parity").charAt(0),
98+
PreferencesData.getInteger("serial.databits"),
99+
new Float(PreferencesData.get("serial.stopbits")).floatValue());
100100
}
101101

102102
public static boolean touchPort(String iname, int irate) throws SerialException {

0 commit comments

Comments
 (0)