diff --git a/src/com/sheepit/client/Configuration.java b/src/com/sheepit/client/Configuration.java index dcde335..584c137 100644 --- a/src/com/sheepit/client/Configuration.java +++ b/src/com/sheepit/client/Configuration.java @@ -52,6 +52,7 @@ public class Configuration { public List> requestTime; private String extras; private boolean autoSignIn; + private String UIType; public Configuration(File cache_dir_, String login_, String password_) { this.login = login_; @@ -69,6 +70,7 @@ public class Configuration { this.requestTime = null; this.extras = ""; this.autoSignIn = false; + this.UIType = null; } public String toString() { @@ -195,6 +197,14 @@ public class Configuration { return this.autoSignIn; } + public void setUIType(String ui) { + this.UIType = ui; + } + + public String getUIType() { + return this.UIType; + } + public void cleanWorkingDirectory() { this.cleanDirectory(this.workingDirectory); this.cleanDirectory(this.storageDirectory); diff --git a/src/com/sheepit/client/standalone/Worker.java b/src/com/sheepit/client/standalone/Worker.java index 2d546a3..06858a7 100644 --- a/src/com/sheepit/client/standalone/Worker.java +++ b/src/com/sheepit/client/standalone/Worker.java @@ -82,7 +82,7 @@ public class Worker { private String extras = null; @Option(name = "-ui", usage = "Specify the user interface to use, default 'swing', available 'oneline', 'text', 'swing' (graphical)", required = false) - private String ui_type = GuiSwing.type; + private String ui_type = null; @Option(name = "-config", usage = "Specify the configuration file", required = false) private String config_file = null; @@ -261,6 +261,10 @@ public class Worker { config.setComputeMethod(compute_method); + if (ui_type != null) { + config.setUIType(ui_type); + } + if (config_file != null) { if (new File(config_file).exists() == false) { System.err.println("Configuration file not found."); @@ -273,7 +277,11 @@ public class Worker { Log.getInstance(config).debug("client version " + config.getJarVersion()); Gui gui; - switch (ui_type) { + String type = config.getUIType(); + if (type == null) { + type = "swing"; + } + switch (type) { case GuiTextOneLine.type: if (config.getPrintLog()) { System.out.println("OneLine UI can not be used if verbose mode is enabled"); @@ -281,6 +289,10 @@ public class Worker { } gui = new GuiTextOneLine(); break; + case GuiText.type: + gui = new GuiText(); + break; + default: case GuiSwing.type: if (java.awt.GraphicsEnvironment.isHeadless()) { System.out.println("Graphical ui can not be launch."); @@ -289,9 +301,6 @@ public class Worker { } gui = new GuiSwing(); break; - default: - gui = new GuiText(); - break; } Client cli = new Client(gui, config, server); gui.setClient(cli); diff --git a/src/com/sheepit/client/standalone/swing/SettingsLoader.java b/src/com/sheepit/client/standalone/swing/SettingsLoader.java index a9116b0..6a1f070 100644 --- a/src/com/sheepit/client/standalone/swing/SettingsLoader.java +++ b/src/com/sheepit/client/standalone/swing/SettingsLoader.java @@ -22,6 +22,7 @@ public class SettingsLoader { private String gpu; private String cacheDir; private String autoSignIn; + private String ui; public SettingsLoader() { path = getDefaultFilePath(); @@ -31,12 +32,13 @@ public class SettingsLoader { path = path_; } - public SettingsLoader(String login_, String password_, ComputeType computeMethod_, GPUDevice gpu_, String cacheDir_, boolean autoSignIn_) { + public SettingsLoader(String login_, String password_, ComputeType computeMethod_, GPUDevice gpu_, String cacheDir_, boolean autoSignIn_, String ui_) { path = getDefaultFilePath(); login = login_; password = password_; cacheDir = cacheDir_; autoSignIn = String.valueOf(autoSignIn_); + ui = ui_; if (computeMethod_ != null) { try { @@ -89,6 +91,10 @@ public class SettingsLoader { prop.setProperty("auto-signin", autoSignIn); } + if (ui != null) { + prop.setProperty("ui", ui); + } + prop.store(output, null); } catch (IOException io) { @@ -113,6 +119,7 @@ public class SettingsLoader { this.gpu = null; this.cacheDir = null; this.autoSignIn = null; + this.ui = null; if (new File(path).exists() == false) { return; @@ -147,6 +154,10 @@ public class SettingsLoader { if (prop.containsKey("auto-signin")) { this.autoSignIn = prop.getProperty("auto-signin"); } + + if (prop.containsKey("ui")) { + this.ui = prop.getProperty("ui"); + } } catch (IOException io) { io.printStackTrace(); @@ -200,6 +211,10 @@ public class SettingsLoader { config.setCacheDir(new File(cacheDir)); } + if (config.getUIType() == null && ui != null) { + config.setUIType(ui); + } + config.setAutoSignIn(Boolean.valueOf(autoSignIn)); } diff --git a/src/com/sheepit/client/standalone/swing/activity/Settings.java b/src/com/sheepit/client/standalone/swing/activity/Settings.java index 3967438..0365a79 100644 --- a/src/com/sheepit/client/standalone/swing/activity/Settings.java +++ b/src/com/sheepit/client/standalone/swing/activity/Settings.java @@ -303,7 +303,7 @@ public class Settings implements Activity { } if (saveFile.isSelected()) { - new SettingsLoader(login.getText(), new String(password.getPassword()), method, selected_gpu, cachePath, autoSignIn.isSelected()).saveFile(); + new SettingsLoader(login.getText(), new String(password.getPassword()), method, selected_gpu, cachePath, autoSignIn.isSelected(), GuiSwing.type).saveFile(); } else { try {