UI type save on configuration file
This commit is contained in:
@@ -52,6 +52,7 @@ public class Configuration {
|
|||||||
public List<Pair<Calendar, Calendar>> requestTime;
|
public List<Pair<Calendar, Calendar>> requestTime;
|
||||||
private String extras;
|
private String extras;
|
||||||
private boolean autoSignIn;
|
private boolean autoSignIn;
|
||||||
|
private String UIType;
|
||||||
|
|
||||||
public Configuration(File cache_dir_, String login_, String password_) {
|
public Configuration(File cache_dir_, String login_, String password_) {
|
||||||
this.login = login_;
|
this.login = login_;
|
||||||
@@ -69,6 +70,7 @@ public class Configuration {
|
|||||||
this.requestTime = null;
|
this.requestTime = null;
|
||||||
this.extras = "";
|
this.extras = "";
|
||||||
this.autoSignIn = false;
|
this.autoSignIn = false;
|
||||||
|
this.UIType = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
@@ -195,6 +197,14 @@ public class Configuration {
|
|||||||
return this.autoSignIn;
|
return this.autoSignIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUIType(String ui) {
|
||||||
|
this.UIType = ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUIType() {
|
||||||
|
return this.UIType;
|
||||||
|
}
|
||||||
|
|
||||||
public void cleanWorkingDirectory() {
|
public void cleanWorkingDirectory() {
|
||||||
this.cleanDirectory(this.workingDirectory);
|
this.cleanDirectory(this.workingDirectory);
|
||||||
this.cleanDirectory(this.storageDirectory);
|
this.cleanDirectory(this.storageDirectory);
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class Worker {
|
|||||||
private String extras = null;
|
private String extras = null;
|
||||||
|
|
||||||
@Option(name = "-ui", usage = "Specify the user interface to use, default 'swing', available 'oneline', 'text', 'swing' (graphical)", required = false)
|
@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)
|
@Option(name = "-config", usage = "Specify the configuration file", required = false)
|
||||||
private String config_file = null;
|
private String config_file = null;
|
||||||
@@ -261,6 +261,10 @@ public class Worker {
|
|||||||
|
|
||||||
config.setComputeMethod(compute_method);
|
config.setComputeMethod(compute_method);
|
||||||
|
|
||||||
|
if (ui_type != null) {
|
||||||
|
config.setUIType(ui_type);
|
||||||
|
}
|
||||||
|
|
||||||
if (config_file != null) {
|
if (config_file != null) {
|
||||||
if (new File(config_file).exists() == false) {
|
if (new File(config_file).exists() == false) {
|
||||||
System.err.println("Configuration file not found.");
|
System.err.println("Configuration file not found.");
|
||||||
@@ -273,7 +277,11 @@ public class Worker {
|
|||||||
Log.getInstance(config).debug("client version " + config.getJarVersion());
|
Log.getInstance(config).debug("client version " + config.getJarVersion());
|
||||||
|
|
||||||
Gui gui;
|
Gui gui;
|
||||||
switch (ui_type) {
|
String type = config.getUIType();
|
||||||
|
if (type == null) {
|
||||||
|
type = "swing";
|
||||||
|
}
|
||||||
|
switch (type) {
|
||||||
case GuiTextOneLine.type:
|
case GuiTextOneLine.type:
|
||||||
if (config.getPrintLog()) {
|
if (config.getPrintLog()) {
|
||||||
System.out.println("OneLine UI can not be used if verbose mode is enabled");
|
System.out.println("OneLine UI can not be used if verbose mode is enabled");
|
||||||
@@ -281,6 +289,10 @@ public class Worker {
|
|||||||
}
|
}
|
||||||
gui = new GuiTextOneLine();
|
gui = new GuiTextOneLine();
|
||||||
break;
|
break;
|
||||||
|
case GuiText.type:
|
||||||
|
gui = new GuiText();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
case GuiSwing.type:
|
case GuiSwing.type:
|
||||||
if (java.awt.GraphicsEnvironment.isHeadless()) {
|
if (java.awt.GraphicsEnvironment.isHeadless()) {
|
||||||
System.out.println("Graphical ui can not be launch.");
|
System.out.println("Graphical ui can not be launch.");
|
||||||
@@ -289,9 +301,6 @@ public class Worker {
|
|||||||
}
|
}
|
||||||
gui = new GuiSwing();
|
gui = new GuiSwing();
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
gui = new GuiText();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
Client cli = new Client(gui, config, server);
|
Client cli = new Client(gui, config, server);
|
||||||
gui.setClient(cli);
|
gui.setClient(cli);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ public class SettingsLoader {
|
|||||||
private String gpu;
|
private String gpu;
|
||||||
private String cacheDir;
|
private String cacheDir;
|
||||||
private String autoSignIn;
|
private String autoSignIn;
|
||||||
|
private String ui;
|
||||||
|
|
||||||
public SettingsLoader() {
|
public SettingsLoader() {
|
||||||
path = getDefaultFilePath();
|
path = getDefaultFilePath();
|
||||||
@@ -31,12 +32,13 @@ public class SettingsLoader {
|
|||||||
path = path_;
|
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();
|
path = getDefaultFilePath();
|
||||||
login = login_;
|
login = login_;
|
||||||
password = password_;
|
password = password_;
|
||||||
cacheDir = cacheDir_;
|
cacheDir = cacheDir_;
|
||||||
autoSignIn = String.valueOf(autoSignIn_);
|
autoSignIn = String.valueOf(autoSignIn_);
|
||||||
|
ui = ui_;
|
||||||
|
|
||||||
if (computeMethod_ != null) {
|
if (computeMethod_ != null) {
|
||||||
try {
|
try {
|
||||||
@@ -89,6 +91,10 @@ public class SettingsLoader {
|
|||||||
prop.setProperty("auto-signin", autoSignIn);
|
prop.setProperty("auto-signin", autoSignIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ui != null) {
|
||||||
|
prop.setProperty("ui", ui);
|
||||||
|
}
|
||||||
|
|
||||||
prop.store(output, null);
|
prop.store(output, null);
|
||||||
}
|
}
|
||||||
catch (IOException io) {
|
catch (IOException io) {
|
||||||
@@ -113,6 +119,7 @@ public class SettingsLoader {
|
|||||||
this.gpu = null;
|
this.gpu = null;
|
||||||
this.cacheDir = null;
|
this.cacheDir = null;
|
||||||
this.autoSignIn = null;
|
this.autoSignIn = null;
|
||||||
|
this.ui = null;
|
||||||
|
|
||||||
if (new File(path).exists() == false) {
|
if (new File(path).exists() == false) {
|
||||||
return;
|
return;
|
||||||
@@ -147,6 +154,10 @@ public class SettingsLoader {
|
|||||||
if (prop.containsKey("auto-signin")) {
|
if (prop.containsKey("auto-signin")) {
|
||||||
this.autoSignIn = prop.getProperty("auto-signin");
|
this.autoSignIn = prop.getProperty("auto-signin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (prop.containsKey("ui")) {
|
||||||
|
this.ui = prop.getProperty("ui");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (IOException io) {
|
catch (IOException io) {
|
||||||
io.printStackTrace();
|
io.printStackTrace();
|
||||||
@@ -200,6 +211,10 @@ public class SettingsLoader {
|
|||||||
config.setCacheDir(new File(cacheDir));
|
config.setCacheDir(new File(cacheDir));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.getUIType() == null && ui != null) {
|
||||||
|
config.setUIType(ui);
|
||||||
|
}
|
||||||
|
|
||||||
config.setAutoSignIn(Boolean.valueOf(autoSignIn));
|
config.setAutoSignIn(Boolean.valueOf(autoSignIn));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -303,7 +303,7 @@ public class Settings implements Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (saveFile.isSelected()) {
|
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 {
|
else {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user