當前位置: 首頁>>代碼示例>>Java>>正文


Java WorkerStateEvent類代碼示例

本文整理匯總了Java中javafx.concurrent.WorkerStateEvent的典型用法代碼示例。如果您正苦於以下問題:Java WorkerStateEvent類的具體用法?Java WorkerStateEvent怎麽用?Java WorkerStateEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


WorkerStateEvent類屬於javafx.concurrent包,在下文中一共展示了WorkerStateEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setOnSuccededAfterService

import javafx.concurrent.WorkerStateEvent; //導入依賴的package包/類
public void setOnSuccededAfterService(TestdataPresenter testdataPresenter, String onSucceededMessage) {
    super.setOnSucceeded((WorkerStateEvent t) -> {
        LoggerFacade.getDefault().debug(this.getClass(), onSucceededMessage);
        
        presenter.setProgressBarInformation(onSucceededMessage);
        
        if (!presenter.getProgressBarPercentInformation().getText().equals("100%")) { // NOI18N
            presenter.getProgressBarPercentInformation().textProperty().unbind();
            presenter.getProgressBarPercentInformation().setText("100%"); // NOI18N
        }
        
        if (testdataPresenter != null) {
            testdataPresenter.cleanUpAfterServices();
        }
    });
}
 
開發者ID:Naoghuman,項目名稱:ABC-List,代碼行數:17,代碼來源:TopicService.java

示例2: performAction

import javafx.concurrent.WorkerStateEvent; //導入依賴的package包/類
private void performAction(WorkerStateEvent event) {
	if (!buttonClicked) {
		return;
	}
	buttonClicked = false;

	ServerInfo serverInfo = (ServerInfo) event.getSource().getValue();

	switch (serverInfo.getServerStatus()) {
		case LOCALLY_ONLINE:
			serverService.requestShutdown();
			break;
		case OFFLINE:
			startServer();
			break;
		case REMOTE_ONLINE:
		case REMOTE_UPLOADING:
		case LOCALLY_UPLOADING:
		case LOCALLY_DOWNLOADING:
			// do nothing
	}
}
 
開發者ID:Azzurite,項目名稱:MinecraftServerSync,代碼行數:23,代碼來源:ServerButton.java

示例3: updateButtonState

import javafx.concurrent.WorkerStateEvent; //導入依賴的package包/類
private void updateButtonState(WorkerStateEvent event) {
	ServerInfo serverInfo = (ServerInfo) event.getSource().getValue();

	switch (serverInfo.getServerStatus()) {
		case REMOTE_ONLINE:
			serverButton.setDisable(true);
			break;
		case OFFLINE:
			serverButton.setText("Start server");
			serverButton.setDisable(false);
			break;
		case REMOTE_UPLOADING:
			serverButton.setDisable(true);
			break;
		case LOCALLY_ONLINE:
			serverButton.setText("Stop server");
			serverButton.setDisable(false);
			break;
		case LOCALLY_UPLOADING:
			serverButton.setDisable(true);
			break;
		case LOCALLY_DOWNLOADING:
			serverButton.setDisable(true);
			break;
	}
}
 
開發者ID:Azzurite,項目名稱:MinecraftServerSync,代碼行數:27,代碼來源:ServerButton.java

示例4: handle

import javafx.concurrent.WorkerStateEvent; //導入依賴的package包/類
@Override
public void handle(WorkerStateEvent event) {

	LOGGER.debug("successed!");
	Object obj = event.getSource().getValue();

	TreeItem<V> root = new TreeItem<>(vRoot);
	tvFiles.setRoot(root);

	int totalSize = 0;
	if (obj != null) {
		Map<String, ObservableList<File>> value = (Map<String, ObservableList<File>>) obj;

		for (String key : value.keySet()) {
			V v = new V();
			v.setFileExtension(key);
			ObservableList<File> list = value.get(key);
			v.setItems(list);
			totalSize += list.size();
			root.getChildren().add(new TreeItem<>(v));
		}
	}
	vRoot.setSize(totalSize);
	service.reset();

}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:27,代碼來源:FilesAnalysisComposite.java

示例5: getUserIdAndSetOrders

import javafx.concurrent.WorkerStateEvent; //導入依賴的package包/類
private void getUserIdAndSetOrders(){
	
	Task<Void> getUserIdTask = new Task<Void>() {
           @Override
           protected Void call() throws Exception {	
           	while(userId == null){
           		
           	}
           	return null;
        }
       };
      new Thread(getUserIdTask).start();
      
      progressIndicator.progressProperty().bind(getUserIdTask.progressProperty());
      progressIndicator.setVisible(true); 
      
      getUserIdTask.setOnSucceeded(new EventHandler<WorkerStateEvent>() {
          @Override
          public void handle(WorkerStateEvent workerStateEvent) {
       	   progressIndicator.setVisible(false);
       	   setOrders();
          }
      });
}
 
開發者ID:TechnionYP5777,項目名稱:SmartCity-ParkingManagement,代碼行數:25,代碼來源:MainScreenController.java

示例6: callAfter

import javafx.concurrent.WorkerStateEvent; //導入依賴的package包/類
public static void callAfter(int mseconds, CallbackVisitor callback) {
    Task<Void> sleeper = new Task<Void>() {
        @Override
        protected Void call() throws Exception {
            try {
                Thread.sleep(mseconds);
            } catch (InterruptedException e) {
                ExceptionAlerter.showException(e);
            }
            return null;
        }
    };
    sleeper.setOnSucceeded(new EventHandler<WorkerStateEvent>() {
        @Override
        public void handle(WorkerStateEvent event) {
            callback.call();
        }
    });
    new Thread(sleeper).start();
}
 
開發者ID:SohanChy,項目名稱:Lipi,代碼行數:21,代碼來源:TimedUpdaterUtil.java

示例7: getAsyncStatList

import javafx.concurrent.WorkerStateEvent; //導入依賴的package包/類
/**
 * Return async stats list
 *
 * @param type
 * @param addData
 */
private void getAsyncStatList(final AsyncStatsType type, final int addData) {
    refreshStatsService = new RefreshingService();
    refreshStatsService.setPeriod(Duration.seconds(Constants.REFRESH_ONE_INTERVAL_SECONDS));
    refreshStatsService.setOnSucceeded((WorkerStateEvent event) -> {
        switch (type) {
            case GLOBAL:
                buildGlobalStat();
                break;
            case PORT:
                buildPortStatTable(addData);
                break;
            case TUI:
                buildPortStatTable(-1);
                break;
            default:
                break;
        }
    });
    refreshStatsService.start();
}
 
開發者ID:exalt-tech,項目名稱:trex-stateless-gui,代碼行數:27,代碼來源:MainViewController.java

示例8: initializeReadingStats

import javafx.concurrent.WorkerStateEvent; //導入依賴的package包/類
/**
 * Initialize reading stats thread
 */
private void initializeReadingStats() {
    readingStatService = new RefreshingService();
    readingStatService.setPeriod(Duration.seconds(Constants.REFRESH_ONE_INTERVAL_SECONDS));
    readingStatService.setOnSucceeded((WorkerStateEvent event) -> {
        currentStatsList = StatsLoader.getInstance().getLoadedStatsList();
        String data = currentStatsList.get("m_cpu_util");
        if (Util.isNullOrEmpty(data)) {
            data = "0";
        }
        updateGaugeSegmentsAndColoring(Double.parseDouble(data));

        ((StatsInfoView) totalTx.getChildren().get(0)).setValue(Util.getFormatted(currentStatsList.get("m_tx_bps"), true, "b/sec"));
        ((StatsInfoView) totalRx.getChildren().get(0)).setValue(Util.getFormatted(currentStatsList.get("m_rx_bps"), true, "b/sec"));
        ((StatsInfoView) totalPPS.getChildren().get(0)).setValue(Util.getFormatted(currentStatsList.get("m_tx_pps"), true, "pkt/sec"));
        ((StatsInfoView) totalStream.getChildren().get(0)).setValue("0");
        ((StatsInfoView) activePort.getChildren().get(0)).setValue(portManager.getActivePort());
        ((StatsInfoView) dropRate.getChildren().get(0)).setValue(Util.getFormatted(currentStatsList.get("m_rx_drop_bps"), true, "b/sec"));
        ((StatsInfoView) queueFull.getChildren().get(0)).setValue(Util.getFormatted(getDiffQueueFull(), true, "pkts"));
        buildPortStatTable();
    });
    readingStatService.start();

    latencyChartController.runChart();
}
 
開發者ID:exalt-tech,項目名稱:trex-stateless-gui,代碼行數:28,代碼來源:DashboardController.java

示例9: DrBookingService

import javafx.concurrent.WorkerStateEvent; //導入依賴的package包/類
public DrBookingService() {
    super(progressLabel);

    addEventHandler(WorkerStateEvent.WORKER_STATE_FAILED, event -> {
        setWorking(false, false);
    });

    addEventHandler(WorkerStateEvent.WORKER_STATE_SCHEDULED, event -> {
        setWorking(true);
    });

    addEventHandler(WorkerStateEvent.WORKER_STATE_SUCCEEDED, event -> {
        setWorking(false);

    });
}
 
開發者ID:DrBookings,項目名稱:drbookings,代碼行數:17,代碼來源:MainController.java

示例10: handleFailureEvent

import javafx.concurrent.WorkerStateEvent; //導入依賴的package包/類
private void handleFailureEvent(WorkerStateEvent event, String messageId) {
    String errorMessage = DEFAULT_ERROR_MESSAGE;
    Throwable exception = event.getSource().getException();
    if (exception != null) {
        if (exception instanceof AuthenticationException) {
            navigator.navigateToLogin(exception.getLocalizedMessage());
            view.enableSearchButton();
            return;
        } else if (exception instanceof ReportNotFoundException) {
            errorMessage = "Delivery report for " + messageId + " was not found.\n" +
                    "Perhaps it did not arrive yet or has already been collected.\n" +
                    "Remember: a delivery report can be received only once per SMS.";
        } else {
            errorMessage += " because " + exception.getLocalizedMessage();
        }
    }
    view.showErrorMessage(errorMessage);
    view.enableSearchButton();
}
 
開發者ID:infobip,項目名稱:infobip-api-java-demo,代碼行數:20,代碼來源:DeliveryReportController.java

示例11: onVersionCheckFinished

import javafx.concurrent.WorkerStateEvent; //導入依賴的package包/類
private void onVersionCheckFinished(WorkerStateEvent event) {
    Optional<GitHubVersion> gitHubVersionOptional = ((VersionCheckerTask) event.getSource()).getValue();
    gitHubVersionOptional.ifPresent(gitHubVersion -> {
        Version currentVersion = new Version(resources.getString("release.version"));
        Version mostRecentVersion = new Version(gitHubVersion.getVersion());

        LOGGER.debug("Most recent github version is {}, this version is {}", mostRecentVersion, currentVersion);
        if (mostRecentVersion.isNewerThan(currentVersion)) {
            Hyperlink link = HyperlinkUtil.createLink(
                    FormattingUtil.getFormatted("worker.updatecheck.available", mostRecentVersion.toString()),
                    gitHubVersion.getUrl()
            );
            mainToolbar.getItems().add(link);
        }
    });
}
 
開發者ID:pbauerochse,項目名稱:youtrack-worklog-viewer,代碼行數:17,代碼來源:MainViewController.java

示例12: SrmDetectionTask

import javafx.concurrent.WorkerStateEvent; //導入依賴的package包/類
public SrmDetectionTask(String title, @Nullable String message, @Nonnull RawDataFile rawDataFile,
    @Nonnull DataPointStore dataStore, @Nullable String nameSuffix) {
  this.rawDataFile = rawDataFile;
  this.dataStore = dataStore;
  this.nameSuffix = nameSuffix;
  this.title = title;
  this.message = message;

  // SRM detection method
  srmDetectionMethod = new SrmDetectionMethod(rawDataFile, dataStore);

  refreshStatus();

  EventHandler<WorkerStateEvent> cancelEvent = new EventHandler<WorkerStateEvent>() {
    @Override
    public void handle(WorkerStateEvent workerEvent) {
      srmDetectionMethod.cancel();
    }
  };

  setOnCancelled(cancelEvent);
}
 
開發者ID:mzmine,項目名稱:mzmine3,代碼行數:23,代碼來源:SrmDetectionTask.java

示例13: ChromatogramBuilderTask

import javafx.concurrent.WorkerStateEvent; //導入依賴的package包/類
public ChromatogramBuilderTask(String title, @Nullable String message,
    @Nonnull RawDataFile rawDataFile, @Nonnull DataPointStore dataStore,
    @Nonnull MaximumMzTolerance mzTolerance, @Nonnull Double noiseLevel,
    @Nonnull Double minDuration, @Nonnull Double minHeight, @Nullable String nameSuffix) {
  this.rawDataFile = rawDataFile;
  this.dataStore = dataStore;
  this.nameSuffix = nameSuffix;
  this.title = title;
  this.message = message;

  // Chromatogram builder method
  chromatogramBuilderMethod = new ChromatogramBuilderMethod(dataStore, rawDataFile, noiseLevel,
      minDuration, minHeight, mzTolerance);

  refreshStatus();

  EventHandler<WorkerStateEvent> cancelEvent = new EventHandler<WorkerStateEvent>() {
    @Override
    public void handle(WorkerStateEvent workerEvent) {
      chromatogramBuilderMethod.cancel();
    }
  };

  setOnCancelled(cancelEvent);
}
 
開發者ID:mzmine,項目名稱:mzmine3,代碼行數:26,代碼來源:ChromatogramBuilderTask.java

示例14: createServiceChain

import javafx.concurrent.WorkerStateEvent; //導入依賴的package包/類
private void createServiceChain(final Service<String> service, final ServiceChain demoControl) {
    service.addEventHandler(WorkerStateEvent.WORKER_STATE_SUCCEEDED, (val) -> {

        final Service<String> service2 = createServiceTwo();

        service2.addEventHandler(WorkerStateEvent.WORKER_STATE_SUCCEEDED, (val2) -> {
            demoControl.stepTwoRectangle.setStroke(Color.GRAY);
            service2.reset();
        });

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        demoControl.progressService.progressProperty().unbind();
        demoControl.progressService.progressProperty().bind(service2.progressProperty());

        demoControl.stepOneRectangle.setStroke(Color.GRAY);
        demoControl.stepTwoRectangle.setStroke(Color.GREEN);
        demoControl.stepTwoRectangle.setVisible(true);
        service2.start();
    });
}
 
開發者ID:amoAHCP,項目名稱:JavaOne2015JavaFXPitfalls,代碼行數:27,代碼來源:ServiceChainDemoMain.java

示例15: bindServiceToControl

import javafx.concurrent.WorkerStateEvent; //導入依賴的package包/類
private void bindServiceToControl(ServiceAndTask demoControl,Service<String> service) {


        demoControl.startService.setOnMouseClicked((val) -> {
            if (!service.isRunning()) {
                service.reset();
                service.start();
                demoControl.labelService.textProperty().bind(service.messageProperty());
            }
        });

        demoControl.labelService.textProperty().bind(service.messageProperty());


        service.addEventHandler(WorkerStateEvent.WORKER_STATE_SUCCEEDED, (val) -> {
            demoControl.labelService.textProperty().unbind();
            demoControl.labelService.setText(service.getValue());
        });

        demoControl.progressService.progressProperty().bind(service.progressProperty());
    }
 
開發者ID:amoAHCP,項目名稱:JavaOne2015JavaFXPitfalls,代碼行數:22,代碼來源:ServiceAndTaskDemo.java


注:本文中的javafx.concurrent.WorkerStateEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。