use of javafx.concurrent.Task in project Retrospector by NonlinearFruit.
the class Retrospector method start.
@Override
public void start(final Stage initStage) throws Exception {
final Task<Parent> task = new Task<Parent>() {
@Override
protected Parent call() throws InterruptedException, IOException {
updateProgress(0, 8);
updateMessage("Loading Database . . .");
DataManager.startDB();
updateProgress(1, 8);
updateMessage("Loading Core . . .");
FXMLLoader ldr = new FXMLLoader(getClass().getResource("/retrospector/fxml/Core.fxml"));
Parent root = ldr.load();
CoreController core = ldr.getController();
updateProgress(2, 8);
updateMessage("Loading Search . . .");
FXMLLoader searchldr = new FXMLLoader(getClass().getResource("/retrospector/fxml/search/SearchTab.fxml"));
searchldr.load();
core.setSearchController(searchldr);
updateProgress(3, 8);
updateMessage("Loading Media . . .");
FXMLLoader medialdr = new FXMLLoader(getClass().getResource("/retrospector/fxml/media/MediaTab.fxml"));
medialdr.load();
core.setMediaController(medialdr);
updateProgress(4, 8);
updateMessage("Loading Review . . .");
FXMLLoader reviewldr = new FXMLLoader(getClass().getResource("/retrospector/fxml/ReviewTab.fxml"));
reviewldr.load();
core.setReviewController(reviewldr);
updateProgress(5, 8);
updateMessage("Loading Chart . . .");
FXMLLoader statldr = new FXMLLoader(getClass().getResource("/retrospector/fxml/chart/StatsTab.fxml"));
statldr.load();
core.setStatsController(statldr);
updateProgress(6, 8);
updateMessage("Loading List . . .");
FXMLLoader listldr = new FXMLLoader(getClass().getResource("/retrospector/fxml/ListsTab.fxml"));
listldr.load();
core.setListController(listldr);
updateProgress(7, 8);
updateMessage("Loading Achievements . . .");
FXMLLoader achieveldr = new FXMLLoader(getClass().getResource("/retrospector/fxml/achievements/AchievementTab.fxml"));
achieveldr.load();
core.setAchieveController(achieveldr);
updateProgress(8, 8);
updateMessage("Done!");
return root;
}
};
showSplash(initStage, task, () -> showMainStage(task.valueProperty().get()));
new Thread(task).start();
}
use of javafx.concurrent.Task in project Gargoyle by callakrsos.
the class SkinPreviewViewComposite method previewTabInit.
@FxPostInitialize
public void previewTabInit() {
Task<Void> task = new Task<Void>() {
@Override
protected Void call() throws Exception {
Thread.sleep(5000L);
Platform.runLater(() -> {
//메뉴바 배경.
{
Background background = mbSample.getBackground();
Color fill = (Color) background.getFills().get(0).getFill();
colorMbSample.setValue(fill);
//메뉴바 텍스트
{
Label lookup = (Label) mbSample.lookup(".label");
Color textFill = (Color) lookup.getTextFill();
colorMbLabelSample.setValue(textFill);
}
}
//Hbox 배경.
{
Background background = hboxSample.getBackground();
Color fill = (Color) background.getFills().get(0).getFill();
colorHboxSample.setValue(fill);
}
{
//선택디지않는 탭 색상 처리.
Set<Node> lookupAll = tabpaneSample.lookupAll(".tab:top");
lookupAll.forEach(lookup -> {
Optional<PseudoClass> findFirst = lookup.getPseudoClassStates().stream().filter(v -> {
return "selected".equals(v.getPseudoClassName());
}).findFirst();
if (findFirst.isPresent()) {
Label selectedTabLabel = (Label) lookup.lookup(".tab-label");
Color textFill = (Color) selectedTabLabel.getTextFill();
colorSelectedTabText.setValue(textFill);
} else {
Label selectedTabLabel = (Label) lookup.lookup(".tab-label");
Color textFill = (Color) selectedTabLabel.getTextFill();
colorUnSelectedTabText.setValue(textFill);
}
});
{
lookupAll.stream().findFirst().ifPresent(n -> {
Pane p = (Pane) n;
Background background = p.getBackground();
Color fill = (Color) background.getFills().get(0).getFill();
colorTabSample1Selected.setValue(fill);
});
}
}
});
return null;
}
};
Window window = this.getScene().getWindow();
if (window != null) {
FxUtil.showLoading(window, task);
} else
FxUtil.showLoading(task);
}
use of javafx.concurrent.Task in project Gargoyle by callakrsos.
the class NrchRealtimeSrchFlowComposite method defineService.
private void defineService() {
/*
* 비동기 실시간 검색어 조회 처리가 기술.
*/
service = new Service<List<RealtimeSearchVO>>() {
@Override
protected Task<List<RealtimeSearchVO>> createTask() {
return new Task<List<RealtimeSearchVO>>() {
@Override
protected List<RealtimeSearchVO> call() throws Exception {
List<RealtimeSearchVO> meta = Collections.emptyList();
try {
meta = NaverRealtimeSrchSupplier.getInstance().getMeta();
} catch (Exception e) {
DialogUtil.showExceptionDailog(e);
}
return meta;
}
};
}
};
service.setOnCancelled(stat -> {
if (State.CANCELLED == stat.getSource().getState()) {
LOGGER.debug("Cancel Requested");
}
});
service.setOnSucceeded(stat -> {
applyResponseTime(DateUtil.getCurrentDateString());
FlowCardComposite value = new FlowCardComposite();
flowCardComposite.set(value);
this.getParent().setCenter(flowCardComposite.get());
FlowCardComposite tmp = flowCardComposite.get();
ObservableList<Node> flowChildrens = tmp.getFlowChildrens();
tmp.setLimitColumn(20);
data.setAll((List<RealtimeSearchVO>) stat.getSource().getValue());
List<VBox> collect = data.stream().map(nodeConverter::apply).flatMap(v -> v.stream()).collect(Collectors.toList());
flowChildrens.setAll(collect);
if (isRecycle.get()) {
WaitThread waitThread = new WaitThread(THREAD_RUNNER_GROUP, choWaitItems.getValue()) {
@Override
public boolean isContinue() {
return isRecycle.get();
}
@Override
public void execute() {
Platform.runLater(() -> {
if (isContinue())
service.restart();
});
}
@Override
public boolean isRecycle() {
return isRecycle.get();
}
};
waitThread.setDaemon(true);
waitThread.start();
}
});
}
use of javafx.concurrent.Task in project loinc2hpo by monarch-initiative.
the class MainController method downloadHPO.
@FXML
public void downloadHPO(ActionEvent e) {
String dirpath = Loinc2HpoPlatform.getLOINC2HPODir().getAbsolutePath();
File f = new File(dirpath);
if (f == null || !(f.exists() && f.isDirectory())) {
logger.trace("Cannot download hp.obo, because directory not existing at " + f.getAbsolutePath());
return;
}
String BASENAME = "hp.obo";
String BASENAME_OWL = "hp.owl";
ProgressIndicator pb = new ProgressIndicator();
javafx.scene.control.Label label = new javafx.scene.control.Label("downloading hp.obo/.owl...");
FlowPane root = new FlowPane();
root.setPadding(new Insets(10));
root.setHgap(10);
root.getChildren().addAll(label, pb);
Scene scene = new Scene(root, 400, 100);
Stage window = new Stage();
window.setTitle("HPO download");
window.setScene(scene);
Task hpodownload = new Downloader(dirpath, HP_OBO_URL, BASENAME, pb);
new Thread(hpodownload).start();
hpodownload = new Downloader(dirpath, HP_OWL_URL, BASENAME_OWL, pb);
new Thread(hpodownload).start();
window.show();
hpodownload.setOnSucceeded(event -> {
window.close();
logger.trace(String.format("Successfully downloaded hpo to %s", dirpath));
String fullpath = String.format("%s%shp.obo", dirpath, File.separator);
String fullpath_owl = String.format("%s%shp.owl", dirpath, File.separator);
model.setPathToHpOboFile(fullpath);
model.setPathToHpOwlFile(fullpath_owl);
model.writeSettings();
configurationComplete.set(isConfigurationCompleted());
});
hpodownload.setOnFailed(event -> {
window.close();
logger.error("Unable to download HPO obo file");
});
// Thread thread = new Thread(hpodownload);
// thread.start();
e.consume();
}
use of javafx.concurrent.Task in project Entitas-Java by Rubentxu.
the class CodeGeneratorApp method handleGenerate.
@FXML
public void handleGenerate(ActionEvent actionEvent) throws IOException {
result.setText("");
progress.setVisible(true);
result.setText("Generating...");
if (props != null)
saveProperties();
// loads the items at another thread, asynchronously
Task loader = new Task<List<CodeGenFile>>() {
{
setOnSucceeded(workerStateEvent -> {
progress.setVisible(false);
result.setText("Success");
});
setOnFailed(workerStateEvent -> {
result.setText("Failed");
getException().printStackTrace();
});
}
@Override
protected List<CodeGenFile> call() throws Exception {
List<ICodeGenerator> codeGenerators = new ArrayList<>();
if (componentsGenerator.isSelected())
codeGenerators.add(new EntityGenerator());
if (componentIndicesGenerator.isSelected())
codeGenerators.add(new ComponentIndicesGenerator());
if (contextsGenerator.isSelected())
codeGenerators.add(new ContextGenerator());
codeGenerators.add(new MatcherGenerator());
codeGenerators.add(new EntitasGenerator());
TypeReflectionProvider provider = new TypeReflectionProvider(fieldComponentFolder.getText());
CodeGeneratorOld generator = new CodeGeneratorOld();
return generator.generate(provider, fieldGeneratedFolder.getText(), codeGenerators);
}
};
Thread loadingThread = new Thread(loader, "generated-loader");
loadingThread.setDaemon(true);
loadingThread.start();
}
Aggregations