added first start up config variable getting
This commit is contained in:
parent
d3a094b83d
commit
e31716db04
@ -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;
|
||||||
@ -69,7 +70,9 @@ public class RootController {
|
|||||||
changeUsername();
|
changeUsername();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new ConfigPersister().saveConfig(".fm/", config);
|
||||||
|
|
||||||
FmFramework.getSessionConfig().getVariable("username").addListener(new VariableListener() {
|
FmFramework.getSessionConfig().getVariable("username").addListener(new VariableListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -205,7 +208,7 @@ public class RootController {
|
|||||||
protected void handleAuth(ActionEvent event) {
|
protected void handleAuth(ActionEvent event) {
|
||||||
authenticate();
|
authenticate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void authenticate() {
|
public void authenticate() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -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
|
||||||
@ -414,11 +395,11 @@ public class RootController {
|
|||||||
protected void handlePrintConfig(ActionEvent event) {
|
protected void handlePrintConfig(ActionEvent event) {
|
||||||
System.out.println(FmFramework.getSessionConfig());
|
System.out.println(FmFramework.getSessionConfig());
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
protected void handleDumpCache(ActionEvent event) {
|
protected void handleDumpCache(ActionEvent event) {
|
||||||
Log log = Logger.getLog();
|
Log log = Logger.getLog();
|
||||||
|
|
||||||
FmFramework.getTrackPool().dumpToLog(log);
|
FmFramework.getTrackPool().dumpToLog(log);
|
||||||
FmFramework.getAlbumPool().dumpToLog(log);
|
FmFramework.getAlbumPool().dumpToLog(log);
|
||||||
FmFramework.getArtistPool().dumpToLog(log);
|
FmFramework.getArtistPool().dumpToLog(log);
|
||||||
|
Loading…
Reference in New Issue
Block a user