Skip to content

Commit 10af59f

Browse files
bitroncmaglie
authored andcommitted
Moved some code from Base to BaseNoGui into new getSketchbookPath() method.
1 parent 443f7a7 commit 10af59f

File tree

2 files changed

+28
-22
lines changed

2 files changed

+28
-22
lines changed

app/src/processing/app/Base.java

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -220,27 +220,7 @@ public Base(String[] args) throws Exception {
220220
if (OSUtils.isMacOS())
221221
ThinkDifferent.init(this);
222222

223-
// Get the sketchbook path, and make sure it's set properly
224-
String sketchbookPath = Preferences.get("sketchbook.path");
225-
226-
// If a value is at least set, first check to see if the folder exists.
227-
// If it doesn't, warn the user that the sketchbook folder is being reset.
228-
if (sketchbookPath != null) {
229-
File sketchbookFolder;
230-
if (BaseNoGui.getPortableFolder() != null)
231-
sketchbookFolder = new File(BaseNoGui.getPortableFolder(), sketchbookPath);
232-
else
233-
sketchbookFolder = absoluteFile(sketchbookPath);
234-
if (!sketchbookFolder.exists()) {
235-
showWarning(_("Sketchbook folder disappeared"),
236-
_("The sketchbook folder no longer exists.\n" +
237-
"Arduino will switch to the default sketchbook\n" +
238-
"location, and create a new sketchbook folder if\n" +
239-
"necessary. Arduino will then stop talking about\n" +
240-
"himself in the third person."), null);
241-
sketchbookPath = null;
242-
}
243-
}
223+
String sketchbookPath = BaseNoGui.getSketchbookPath();
244224

245225
// If no path is set, get the default sketchbook folder for this platform
246226
if (sketchbookPath == null) {

app/src/processing/app/BaseNoGui.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,32 @@ static public File getSketchbookLibrariesFolder() {
254254
return libdir;
255255
}
256256

257+
static public String getSketchbookPath() {
258+
// Get the sketchbook path, and make sure it's set properly
259+
String sketchbookPath = Preferences.get("sketchbook.path");
260+
261+
// If a value is at least set, first check to see if the folder exists.
262+
// If it doesn't, warn the user that the sketchbook folder is being reset.
263+
if (sketchbookPath != null) {
264+
File sketchbookFolder;
265+
if (BaseNoGui.getPortableFolder() != null)
266+
sketchbookFolder = new File(BaseNoGui.getPortableFolder(), sketchbookPath);
267+
else
268+
sketchbookFolder = absoluteFile(sketchbookPath);
269+
if (!sketchbookFolder.exists()) {
270+
showWarning(_("Sketchbook folder disappeared"),
271+
_("The sketchbook folder no longer exists.\n" +
272+
"Arduino will switch to the default sketchbook\n" +
273+
"location, and create a new sketchbook folder if\n" +
274+
"necessary. Arduino will then stop talking about\n" +
275+
"himself in the third person."), null);
276+
sketchbookPath = null;
277+
}
278+
}
279+
280+
return sketchbookPath;
281+
}
282+
257283
public static TargetBoard getTargetBoard() {
258284
String boardId = PreferencesData.get("board");
259285
return getTargetPlatform().getBoard(boardId);
@@ -552,7 +578,7 @@ static protected void processBoardArgument(String selectBoard) {
552578
if (targetBoard.getMenuLabel(key, value) == null)
553579
showError(null, I18n.format(_("{0}: Invalid option for \"{1}\" option for board \"{2}\""), value, key, targetBoard.getId()), 3);
554580

555-
Preferences.set("custom_" + key, targetBoard.getId() + "_" + value);
581+
PreferencesData.set("custom_" + key, targetBoard.getId() + "_" + value);
556582
}
557583
}
558584
}

0 commit comments

Comments
 (0)