use of com.kyj.fx.voeditor.visual.component.FlowCardComposite 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();
}
});
}
Aggregations