Improvement: allow multi config file support
This commit is contained in:
@@ -40,6 +40,7 @@ public class Configuration {
|
|||||||
CPU_GPU, CPU, GPU
|
CPU_GPU, CPU, GPU
|
||||||
} // accept job for ...
|
} // accept job for ...
|
||||||
|
|
||||||
|
private String configFilePath;
|
||||||
public File workingDirectory;
|
public File workingDirectory;
|
||||||
public File storageDirectory; // for permanent storage (binary archive)
|
public File storageDirectory; // for permanent storage (binary archive)
|
||||||
public boolean userHasSpecifiedACacheDir;
|
public boolean userHasSpecifiedACacheDir;
|
||||||
@@ -64,6 +65,7 @@ public class Configuration {
|
|||||||
private String hostname;
|
private String hostname;
|
||||||
|
|
||||||
public Configuration(File cache_dir_, String login_, String password_) {
|
public Configuration(File cache_dir_, String login_, String password_) {
|
||||||
|
this.configFilePath = null;
|
||||||
this.login = login_;
|
this.login = login_;
|
||||||
this.password = password_;
|
this.password = password_;
|
||||||
this.proxy = null;
|
this.proxy = null;
|
||||||
@@ -93,6 +95,14 @@ public class Configuration {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("Configuration (workingDirectory '%s')", this.workingDirectory.getAbsolutePath());
|
return String.format("Configuration (workingDirectory '%s')", this.workingDirectory.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getConfigFilePath() {
|
||||||
|
return this.configFilePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConfigPath(String val) {
|
||||||
|
this.configFilePath = val;
|
||||||
|
}
|
||||||
|
|
||||||
public String login() {
|
public String login() {
|
||||||
return this.login;
|
return this.login;
|
||||||
|
|||||||
@@ -55,16 +55,22 @@ public class SettingsLoader {
|
|||||||
private String tileSize;
|
private String tileSize;
|
||||||
private int priority;
|
private int priority;
|
||||||
|
|
||||||
public SettingsLoader() {
|
|
||||||
path = getDefaultFilePath();
|
|
||||||
}
|
|
||||||
|
|
||||||
public SettingsLoader(String path_) {
|
public SettingsLoader(String path_) {
|
||||||
path = path_;
|
if (path_ == null) {
|
||||||
|
path = getDefaultFilePath();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
path = path_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SettingsLoader(String login_, String password_, String proxy_, String hostname_, ComputeType computeMethod_, GPUDevice gpu_, int cores_, int maxRam_, int maxRenderTime_, String cacheDir_, boolean autoSignIn_, String ui_, String tileSize_, int priority_) {
|
public SettingsLoader(String path_, String login_, String password_, String proxy_, String hostname_, ComputeType computeMethod_, GPUDevice gpu_, int cores_, int maxRam_, int maxRenderTime_, String cacheDir_, boolean autoSignIn_, String ui_, String tileSize_, int priority_) {
|
||||||
path = getDefaultFilePath();
|
if (path_ == null) {
|
||||||
|
path = getDefaultFilePath();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
path = path_;
|
||||||
|
}
|
||||||
login = login_;
|
login = login_;
|
||||||
password = password_;
|
password = password_;
|
||||||
proxy = proxy_;
|
proxy = proxy_;
|
||||||
|
|||||||
@@ -291,6 +291,7 @@ public class Worker {
|
|||||||
System.err.println("Aborting");
|
System.err.println("Aborting");
|
||||||
System.exit(2);
|
System.exit(2);
|
||||||
}
|
}
|
||||||
|
config.setConfigPath(config_file);
|
||||||
new SettingsLoader(config_file).merge(config);
|
new SettingsLoader(config_file).merge(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public class Settings implements Activity {
|
|||||||
@Override
|
@Override
|
||||||
public void show() {
|
public void show() {
|
||||||
Configuration config = parent.getConfiguration();
|
Configuration config = parent.getConfiguration();
|
||||||
new SettingsLoader().merge(config);
|
new SettingsLoader(config.getConfigFilePath()).merge(config);
|
||||||
|
|
||||||
List<GPUDevice> gpus = GPU.listDevices(config);
|
List<GPUDevice> gpus = GPU.listDevices(config);
|
||||||
|
|
||||||
@@ -617,14 +617,7 @@ public class Settings implements Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (saveFile.isSelected()) {
|
if (saveFile.isSelected()) {
|
||||||
new SettingsLoader(login.getText(), new String(password.getPassword()), proxyText, hostnameText, method, selected_gpu, cpu_cores, max_ram, max_rendertime, cachePath, autoSignIn.isSelected(), GuiSwing.type, tile, priority.getValue()).saveFile();
|
new SettingsLoader(config.getConfigFilePath(), login.getText(), new String(password.getPassword()), proxyText, hostnameText, method, selected_gpu, cpu_cores, max_ram, max_rendertime, cachePath, autoSignIn.isSelected(), GuiSwing.type, tile, priority.getValue()).saveFile();
|
||||||
}
|
|
||||||
else {
|
|
||||||
try {
|
|
||||||
new File(new SettingsLoader().getFilePath()).delete();
|
|
||||||
}
|
|
||||||
catch (SecurityException e3) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user