Better code for loading file (still broken)
This commit is contained in:
parent
2715b66d5b
commit
7414b3caa5
1 changed files with 18 additions and 23 deletions
|
@ -5,7 +5,6 @@ import com.jfoenix.controls.JFXSnackbar;
|
||||||
import com.jfoenix.controls.JFXSpinner;
|
import com.jfoenix.controls.JFXSpinner;
|
||||||
import es.kauron.estraba.App;
|
import es.kauron.estraba.App;
|
||||||
import es.kauron.estraba.model.DataBundle;
|
import es.kauron.estraba.model.DataBundle;
|
||||||
import javafx.application.Platform;
|
|
||||||
import javafx.concurrent.Task;
|
import javafx.concurrent.Task;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
@ -66,38 +65,34 @@ public class SplashController implements Initializable{
|
||||||
errorLoading();
|
errorLoading();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Task<Void> task = new Task<Void>() {
|
Task<DataBundle> task = new Task<DataBundle>() {
|
||||||
@Override
|
@Override
|
||||||
protected Void call() throws Exception {
|
protected DataBundle call() throws Exception {
|
||||||
try {
|
try {
|
||||||
DataBundle bundle = DataBundle.loadFrom(file);
|
updateValue(DataBundle.loadFrom(file));
|
||||||
FXMLLoader loader = new FXMLLoader(
|
succeeded();
|
||||||
App.class.getResource("fxml/Dashboard.fxml"), App.GENERAL_BUNDLE);
|
|
||||||
Parent root = loader.load();
|
|
||||||
|
|
||||||
Stage stage = new Stage();
|
|
||||||
stage.getIcons().add(new Image(App.class.getResource("img/icon.png").toString()));
|
|
||||||
stage.setTitle(App.GENERAL_BUNDLE.getString("app.title"));
|
|
||||||
stage.setResizable(false);
|
|
||||||
stage.setScene(new Scene(root));
|
|
||||||
|
|
||||||
// Begin awesomewm code
|
|
||||||
stage.setMinHeight(500);
|
|
||||||
stage.setMinWidth(800);
|
|
||||||
stage.setResizable(false);
|
|
||||||
// End awesomewm code
|
|
||||||
stage.show();
|
|
||||||
loader.<DashboardController>getController().postInit(bundle);
|
|
||||||
Platform.runLater(() -> ((Stage) root.getScene().getWindow()).close());
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
updateValue(null);
|
||||||
errorLoading();
|
errorLoading();
|
||||||
}
|
}
|
||||||
return null;
|
return getValue();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Thread t = new Thread(task);
|
Thread t = new Thread(task);
|
||||||
t.setDaemon(true);
|
t.setDaemon(true);
|
||||||
t.start();
|
t.start();
|
||||||
|
task.setOnSucceeded(state -> {
|
||||||
|
DataBundle bundle = (DataBundle) state.getSource().getValue();
|
||||||
|
if (bundle == null) errorLoading();
|
||||||
|
FXMLLoader loader = new FXMLLoader(
|
||||||
|
App.class.getResource("fxml/Dashboard.fxml"), App.GENERAL_BUNDLE);
|
||||||
|
Parent parent = null;
|
||||||
|
try {
|
||||||
|
parent = loader.load();
|
||||||
|
} catch (IOException e) {errorLoading();}
|
||||||
|
loader.<DashboardController>getController().postInit(bundle);
|
||||||
|
((Stage) root.getScene().getWindow()).setScene(new Scene(parent));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Reference in a new issue