Search in sources :

Example 1 with FlowCardComposite

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();
        }
    });
}
Also used : IntStream(java.util.stream.IntStream) Button(javafx.scene.control.Button) Pos(javafx.geometry.Pos) MouseButton(javafx.scene.input.MouseButton) RealtimeSearchVO(com.kyj.fx.voeditor.visual.framework.RealtimeSearchVO) LoggerFactory(org.slf4j.LoggerFactory) FXCollections(javafx.collections.FXCollections) DialogUtil(com.kyj.fx.voeditor.visual.util.DialogUtil) VBox(javafx.scene.layout.VBox) Function(java.util.function.Function) RealtimeSearchItemVO(com.kyj.fx.voeditor.visual.framework.RealtimeSearchItemVO) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) Task(javafx.concurrent.Task) Insets(javafx.geometry.Insets) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ContextMenu(javafx.scene.control.ContextMenu) State(javafx.concurrent.Worker.State) ExecutorService(java.util.concurrent.ExecutorService) HBox(javafx.scene.layout.HBox) ObjectProperty(javafx.beans.property.ObjectProperty) Logger(org.slf4j.Logger) Label(javafx.scene.control.Label) MenuItem(javafx.scene.control.MenuItem) TitledPane(javafx.scene.control.TitledPane) CloseableParent(com.kyj.fx.voeditor.visual.main.layout.CloseableParent) Node(javafx.scene.Node) IOException(java.io.IOException) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) Service(javafx.concurrent.Service) Collectors(java.util.stream.Collectors) ChoiceBox(javafx.scene.control.ChoiceBox) GoogleTrendComposite(com.kyj.fx.voeditor.visual.component.google.trend.GoogleTrendComposite) Platform(javafx.application.Platform) Cursor(javafx.scene.Cursor) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) List(java.util.List) BooleanProperty(javafx.beans.property.BooleanProperty) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) NaverRealtimeSrchSupplier(com.kyj.fx.voeditor.visual.suppliers.NaverRealtimeSrchSupplier) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) FlowCardComposite(com.kyj.fx.voeditor.visual.component.FlowCardComposite) DateUtil(com.kyj.fx.voeditor.visual.util.DateUtil) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) Collections(java.util.Collections) ExecutorDemons(com.kyj.fx.voeditor.visual.framework.thread.ExecutorDemons) SharedMemory(com.kyj.fx.voeditor.visual.momory.SharedMemory) Task(javafx.concurrent.Task) Node(javafx.scene.Node) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) IOException(java.io.IOException) RealtimeSearchVO(com.kyj.fx.voeditor.visual.framework.RealtimeSearchVO) FlowCardComposite(com.kyj.fx.voeditor.visual.component.FlowCardComposite) List(java.util.List) ObservableList(javafx.collections.ObservableList) VBox(javafx.scene.layout.VBox)

Aggregations

FlowCardComposite (com.kyj.fx.voeditor.visual.component.FlowCardComposite)1 GoogleTrendComposite (com.kyj.fx.voeditor.visual.component.google.trend.GoogleTrendComposite)1 RealtimeSearchItemVO (com.kyj.fx.voeditor.visual.framework.RealtimeSearchItemVO)1 RealtimeSearchVO (com.kyj.fx.voeditor.visual.framework.RealtimeSearchVO)1 ExecutorDemons (com.kyj.fx.voeditor.visual.framework.thread.ExecutorDemons)1 CloseableParent (com.kyj.fx.voeditor.visual.main.layout.CloseableParent)1 SharedMemory (com.kyj.fx.voeditor.visual.momory.SharedMemory)1 NaverRealtimeSrchSupplier (com.kyj.fx.voeditor.visual.suppliers.NaverRealtimeSrchSupplier)1 DateUtil (com.kyj.fx.voeditor.visual.util.DateUtil)1 DialogUtil (com.kyj.fx.voeditor.visual.util.DialogUtil)1 FxUtil (com.kyj.fx.voeditor.visual.util.FxUtil)1 ValueUtil (com.kyj.fx.voeditor.visual.util.ValueUtil)1 IOException (java.io.IOException)1 Collections (java.util.Collections)1 List (java.util.List)1 ExecutorService (java.util.concurrent.ExecutorService)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1