Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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
  • Loading branch information
cmaglie committed Nov 25, 2016
commit cf54cce6608010ac7d6a1007edea9953d796b7fc
8 changes: 6 additions & 2 deletions app/src/cc/arduino/view/SplashScreenHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@ public class SplashScreenHelper {

public SplashScreenHelper(SplashScreen splash) {
this.splash = splash;
Toolkit tk = Toolkit.getDefaultToolkit();
desktopHints = (Map) tk.getDesktopProperty("awt.font.desktophints");
if (splash != null) {
Toolkit tk = Toolkit.getDefaultToolkit();
desktopHints = (Map) tk.getDesktopProperty("awt.font.desktophints");
} else {
desktopHints = null;
}
}

public void splashText(String text) {
Expand Down
29 changes: 18 additions & 11 deletions app/src/processing/app/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public class Base {
private static boolean commandLine;
public static volatile Base INSTANCE;

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

BaseNoGui.initPortableFolder();

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

splashScreenHelper.splashText(tr("Loading configuration..."));
CommandlineParser parser = new CommandlineParser(args);
parser.parseArgumentsPhase1();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now parseArgumentsPhase1 is moved up this far, it might be good to move it even further up so BaseNoGui.initParameters can just use the --preferences-file value as parsed by parser, instead of having to parse it iself. From a quick glance of parseArgumentsPhase1, it seems this does not depend on the preferences file being loaded? This should probably be a different commit, of course.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately parseArgumentsPhase1 depends on preferences being loaded, it uses PreferencesData in 3 or 4 places. Of course this smells like a bad design, the CommandLineParser class should only parse the command line and actions should be taken outside. I guess it's the result of trying to keep low the amount of changes involved in previous refactorings.

(again, while doing this PR I tried also to fix this one, but dropped this task to focus on solving the X11 issue)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Sounds like the commandline parsing needs another refactor after this one then (or, at least a parseArgumentsPhase0 to just parse the preferences path).


SplashScreenHelper splash;
if (parser.isGuiMode()) {
splash = new SplashScreenHelper(SplashScreen.getSplashScreen());
} else {
splash = new SplashScreenHelper(null);
}

splash.splashText(tr("Loading configuration..."));

BaseNoGui.initVersion();

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

BaseNoGui.notifier = new GUIUserNotifier(this);

CommandlineParser parser = new CommandlineParser(args);
parser.parseArgumentsPhase1();

BaseNoGui.checkInstallationFolder();

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

splashScreenHelper.splashText(tr("Initializing packages..."));
splash.splashText(tr("Initializing packages..."));
BaseNoGui.initPackages();
splashScreenHelper.splashText(tr("Preparing boards..."));
splash.splashText(tr("Preparing boards..."));
rebuildBoardsMenu();
rebuildProgrammerMenu();

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

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

if (parser.isUploadMode()) {
splashScreenHelper.splashText(tr("Verifying and uploading..."));
splash.splashText(tr("Verifying and uploading..."));
editor.exportHandler.run();
} else {
splashScreenHelper.splashText(tr("Verifying..."));
splash.splashText(tr("Verifying..."));
editor.runHandler.run();
}

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

installKeyboardInputMap();

Expand Down