use of com.insightfullogic.honest_profiler.ports.javafx.model.task.InitializeProfileTask in project honest-profiler by jvm-profiling-tools.
the class RootController method createNewProfile.
// Profile-related Helper Methods
/**
* Create a {@link Tab} which will contain the Views for a newly opened profile.
* <p>
*
* @param source the source of the profile
* @param live a boolean indicating whether the source is "live"
*/
private void createNewProfile(Object source, boolean live) {
Tab tab = newLoadingTab();
ProfileRootController controller = loadViewIntoTab(FXML_PROFILE_ROOT, tab);
tab.getContent().setVisible(false);
Task<ProfileContext> task = new InitializeProfileTask(appCtx(), source, live);
task.setOnSucceeded(event -> handleNewProfile(tab, controller, task.getValue()));
task.setOnFailed(event -> {
profileTabs.getTabs().remove(tab);
showExceptionDialog(appCtx(), appCtx().textFor(TITLE_DIALOG_ERR_OPENPROFILE), appCtx().textFor(HEADER_DIALOG_ERR_OPENPROFILE), appCtx().textFor(MESSAGE_DIALOG_ERR_OPENPROFILE), task.getException());
});
task.setOnCancelled(event -> {
profileTabs.getTabs().remove(tab);
showErrorDialog(appCtx().textFor(TITLE_DIALOG_ERR_OPENPROFILE), appCtx().textFor(HEADER_DIALOG_ERR_OPENPROFILE), appCtx().textFor(MESSAGE_DIALOG_ERR_TASKCANCELED));
});
appCtx().execute(task);
}
Aggregations