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.
This commit is contained in:
Matthijs Kooijman 2013-10-29 19:10:43 +01:00
parent c6795dde73
commit 9196a8d943
2 changed files with 10 additions and 11 deletions

View File

@ -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");

View File

@ -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();
}