本文整理匯總了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();
}
});
}
示例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
}
}
示例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;
}
}
示例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();
}
示例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();
}
});
}
示例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();
}
示例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();
}
示例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();
}
示例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);
});
}
示例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();
}
示例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);
}
});
}
示例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);
}
示例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);
}
示例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();
});
}
示例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());
}