Skip to content

Commit cf54cce

Browse files
committed
SplashScreenHelper output progress in console for text-only mode
This commit makes this changes: - SplashScreenHelper is now local in Base constructor - if SplashScreenHelper is instantiated with a null SplashScreen instance then it outputs progress in console and avoid to make calls to Swing toolkit - The parsing of command line arguments is anticipated so we can determine if we are in command line or GUI mode early and setup objects that produces output to not use graphics toolkits. - In this case the SplashScreenHelper is initialized with a real splashscreen only if we are in GUI mode
1 parent fbe6bf3 commit cf54cce

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

app/src/cc/arduino/view/SplashScreenHelper.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,12 @@ public class SplashScreenHelper {
5151

5252
public SplashScreenHelper(SplashScreen splash) {
5353
this.splash = splash;
54-
Toolkit tk = Toolkit.getDefaultToolkit();
55-
desktopHints = (Map) tk.getDesktopProperty("awt.font.desktophints");
54+
if (splash != null) {
55+
Toolkit tk = Toolkit.getDefaultToolkit();
56+
desktopHints = (Map) tk.getDesktopProperty("awt.font.desktophints");
57+
} else {
58+
desktopHints = null;
59+
}
5660
}
5761

5862
public void splashText(String text) {

app/src/processing/app/Base.java

+18-11
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ public class Base {
8484
private static boolean commandLine;
8585
public static volatile Base INSTANCE;
8686

87-
public static SplashScreenHelper splashScreenHelper = new SplashScreenHelper(SplashScreen.getSplashScreen());
8887
public static Map<String, Object> FIND_DIALOG_STATE = new HashMap<>();
8988
private final ContributionInstaller contributionInstaller;
9089
private final LibraryInstaller libraryInstaller;
@@ -195,9 +194,20 @@ public Base(String[] args) throws Exception {
195194

196195
BaseNoGui.initPortableFolder();
197196

197+
// Look for a possible "--preferences-file" parameter and load preferences
198198
BaseNoGui.initParameters(args);
199199

200-
splashScreenHelper.splashText(tr("Loading configuration..."));
200+
CommandlineParser parser = new CommandlineParser(args);
201+
parser.parseArgumentsPhase1();
202+
203+
SplashScreenHelper splash;
204+
if (parser.isGuiMode()) {
205+
splash = new SplashScreenHelper(SplashScreen.getSplashScreen());
206+
} else {
207+
splash = new SplashScreenHelper(null);
208+
}
209+
210+
splash.splashText(tr("Loading configuration..."));
201211

202212
BaseNoGui.initVersion();
203213

@@ -224,9 +234,6 @@ public Base(String[] args) throws Exception {
224234

225235
BaseNoGui.notifier = new GUIUserNotifier(this);
226236

227-
CommandlineParser parser = new CommandlineParser(args);
228-
parser.parseArgumentsPhase1();
229-
230237
BaseNoGui.checkInstallationFolder();
231238

232239
// If no path is set, get the default sketchbook folder for this platform
@@ -241,9 +248,9 @@ public Base(String[] args) throws Exception {
241248
}
242249
}
243250

244-
splashScreenHelper.splashText(tr("Initializing packages..."));
251+
splash.splashText(tr("Initializing packages..."));
245252
BaseNoGui.initPackages();
246-
splashScreenHelper.splashText(tr("Preparing boards..."));
253+
splash.splashText(tr("Preparing boards..."));
247254
rebuildBoardsMenu();
248255
rebuildProgrammerMenu();
249256

@@ -372,7 +379,7 @@ public Base(String[] args) throws Exception {
372379
System.exit(0);
373380

374381
} else if (parser.isVerifyOrUploadMode()) {
375-
splashScreenHelper.close();
382+
splash.close();
376383
// Set verbosity for command line build
377384
PreferencesData.set("build.verbose", "" + parser.isDoVerboseBuild());
378385
PreferencesData.set("upload.verbose", "" + parser.isDoVerboseUpload());
@@ -385,10 +392,10 @@ public Base(String[] args) throws Exception {
385392
Editor editor = editors.get(0);
386393

387394
if (parser.isUploadMode()) {
388-
splashScreenHelper.splashText(tr("Verifying and uploading..."));
395+
splash.splashText(tr("Verifying and uploading..."));
389396
editor.exportHandler.run();
390397
} else {
391-
splashScreenHelper.splashText(tr("Verifying..."));
398+
splash.splashText(tr("Verifying..."));
392399
editor.runHandler.run();
393400
}
394401

@@ -400,7 +407,7 @@ public Base(String[] args) throws Exception {
400407
// No errors exit gracefully
401408
System.exit(0);
402409
} else if (parser.isGuiMode()) {
403-
splashScreenHelper.splashText(tr("Starting..."));
410+
splash.splashText(tr("Starting..."));
404411

405412
installKeyboardInputMap();
406413

0 commit comments

Comments
 (0)