added first start up config variable getting

This commit is contained in:
aj 2019-05-22 13:41:20 +01:00
parent d3a094b83d
commit e31716db04

View File

@ -15,6 +15,7 @@ import javafx.event.EventHandler;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.stage.FileChooser; import javafx.stage.FileChooser;
import sarsoo.fmframework.config.Config; import sarsoo.fmframework.config.Config;
import sarsoo.fmframework.config.ConfigPersister;
import sarsoo.fmframework.config.ConfigVariable; import sarsoo.fmframework.config.ConfigVariable;
import sarsoo.fmframework.config.VariableEvent; import sarsoo.fmframework.config.VariableEvent;
import sarsoo.fmframework.config.VariableListener; import sarsoo.fmframework.config.VariableListener;
@ -70,6 +71,8 @@ public class RootController {
} }
} }
new ConfigPersister().saveConfig(".fm/", config);
FmFramework.getSessionConfig().getVariable("username").addListener(new VariableListener() { FmFramework.getSessionConfig().getVariable("username").addListener(new VariableListener() {
@Override @Override
@ -250,45 +253,23 @@ public class RootController {
} }
public void changeUsername() { public void changeUsername() {
Service<Void> service = new Service<Void>() {
@Override
protected Task<Void> createTask() {
return new Task<Void>() {
@Override
protected Void call() throws Exception {
String username = JOptionPane.showInputDialog("enter username:"); String username = JOptionPane.showInputDialog("enter username:");
if (username != null) { if (username != null) {
FmFramework.getSessionConfig().getVariable("username").setValue(username); FmFramework.getSessionConfig().addVariable(new ConfigVariable("username", username));
} }
return null;
}
};
}
};
service.start();
} }
public void setApiKey() { public void setApiKey() {
Service<Void> service = new Service<Void>() {
@Override
protected Task<Void> createTask() {
return new Task<Void>() {
@Override
protected Void call() throws Exception {
String apiKey = JOptionPane.showInputDialog("enter api key:"); String apiKey = JOptionPane.showInputDialog("enter api key:");
if (apiKey != null) { if (apiKey != null) {
FmFramework.getSessionConfig().getVariable("api_key").setValue(apiKey); FmFramework.getSessionConfig().addVariable(new ConfigVariable("api_key", apiKey));
} }
return null;
}
};
}
};
service.start();
} }
@FXML @FXML