use of javafx.concurrent.Service 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.Service in project Gargoyle by callakrsos.
the class BaseInfoComposite method start.
/**
*
* 코드 분석 시작 처리.
* @작성자 : KYJ
* @작성일 : 2017. 2. 3.
*/
public void start() {
// 동적처리에 따라 API 함수 수정.
FileUtil.consumeJavaParser(targetFile, cu -> {
NameExpr name = cu.getPackage().getName();
lblPackage.setText(name.toString());
String importStatement = cu.getImports().stream().map(im -> im.getName().toString()).collect(Collectors.joining(","));
lblImports.setText(importStatement);
Service<Void> service = new Service<Void>() {
@Override
protected Task<Void> createTask() {
return new Task<Void>() {
@Override
protected Void call() throws Exception {
new MethodVisitor(v -> {
methodData.add(v);
}).visit(cu, null);
return null;
}
};
}
};
service.start();
}, err -> {
LOGGER.error(ValueUtil.toString(err));
});
}
Aggregations