UI type save on configuration file
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user