From 9196a8d943cb1f2f66b466b1a7055dec444d3dd8 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Tue, 29 Oct 2013 19:10:43 +0100 Subject: [PATCH] Don't show the GUI on --verify or --upload These are intended to be ran from the commandline, so showing the GUI doesn't make so much sense. This is not quite the perfect solution yet, because an Editor object and all kinds of GUI objects are still created. This commit only prevents them from being visible, which is a nice first step, but not quite pretty yet. However, to do it properly, some code should be moved out of the Editor class, so that's a bit more work. Additionally, any messages shown with Base::showError and friends still create a popup, they probably shouldn't do this either. --- app/src/processing/app/Base.java | 15 ++++++--------- app/src/processing/app/EditorStatus.java | 6 ++++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 700d3b056..aa9c17b69 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -399,7 +399,7 @@ public class Base { path = new File(currentDirectory, path).getAbsolutePath(); } - if (handleOpen(path) == null) { + if (handleOpen(path, nextEditorLocation(), !(doUpload || doVerify)) == null) { String mess = I18n.format(_("Failed to open sketch: \"{0}\""), path); // Open failure is fatal in upload/verify mode if (doUpload || doVerify) @@ -416,10 +416,6 @@ public class Base { Editor editor = editors.get(0); - // Wait until editor is initialized - while (!editor.status.isInitialized()) - Thread.sleep(10); - // Do board selection if requested processBoardArgument(selectBoard); @@ -574,7 +570,7 @@ public class Base { location = nextEditorLocation(); } // If file did not exist, null will be returned for the Editor - if (handleOpen(path, location) != null) { + if (handleOpen(path, location, true) != null) { opened++; } } @@ -888,11 +884,11 @@ public class Base { * @throws Exception */ public Editor handleOpen(String path) throws Exception { - return handleOpen(path, nextEditorLocation()); + return handleOpen(path, nextEditorLocation(), true); } - protected Editor handleOpen(String path, int[] location) throws Exception { + protected Editor handleOpen(String path, int[] location, boolean showEditor) throws Exception { // System.err.println("entering handleOpen " + path); File file = new File(path); @@ -960,7 +956,8 @@ public class Base { // now that we're ready, show the window // (don't do earlier, cuz we might move it based on a window being closed) - editor.setVisible(true); + if (showEditor) + editor.setVisible(true); // System.err.println("exiting handleOpen"); diff --git a/app/src/processing/app/EditorStatus.java b/app/src/processing/app/EditorStatus.java index 5dd330b1a..e09b5b0f9 100644 --- a/app/src/processing/app/EditorStatus.java +++ b/app/src/processing/app/EditorStatus.java @@ -113,7 +113,8 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ { public void notice(String message) { mode = NOTICE; this.message = message; - copyErrorButton.setVisible(false); + if (copyErrorButton != null) + copyErrorButton.setVisible(false); //update(); repaint(); } @@ -126,7 +127,8 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ { public void error(String message) { mode = ERR; this.message = message; - copyErrorButton.setVisible(true); + if (copyErrorButton != null) + copyErrorButton.setVisible(true); repaint(); }