List of usage examples for javafx.concurrent Service Service
protected Service()
From source file:herudi.controller.controllSplash.java
private void longStart() { Service<ApplicationContext> service = new Service<ApplicationContext>() { @Override/*from w ww.j a v a 2s .com*/ protected Task<ApplicationContext> createTask() { return new Task<ApplicationContext>() { @Override protected ApplicationContext call() throws Exception { ApplicationContext appContex = config.getInstance().getApplicationContext(); int max = appContex.getBeanDefinitionCount(); updateProgress(0, max); for (int k = 0; k < max; k++) { Thread.sleep(50); updateProgress(k + 1, max); } return appContex; } }; } }; service.start(); service.setOnRunning((WorkerStateEvent event) -> { new FadeInLeftTransition(lblWelcome).play(); new FadeInRightTransition(lblRudy).play(); new FadeInTransition(vboxBottom).play(); }); service.setOnSucceeded((WorkerStateEvent event) -> { config2 config = new config2(); config.newStage(stage, lblClose, "/herudi/view/login.fxml", "Sample Apps", true, StageStyle.UNDECORATED, false); }); }
From source file:com.toyota.carservice.controller.SplashController.java
private void longStart() { Service<ApplicationContext> service = new Service<ApplicationContext>() { @Override//from w ww .j a va 2s . co m protected Task<ApplicationContext> createTask() { return new Task<ApplicationContext>() { @Override protected ApplicationContext call() throws Exception { ApplicationContext appContex = config.getInstance().getApplicationContext(); int max = appContex.getBeanDefinitionCount(); updateProgress(0, max); System.out.println(PathUtil.getRootPath()); File file = new File(PathUtil.getRootPath()); if (!file.exists()) { file.mkdir(); } if (max < 50) { max = 50; } for (int k = 0; k < max; k++) { Thread.sleep(50); updateProgress(k + 1, max); } return appContex; } }; } }; service.start(); service.setOnRunning((WorkerStateEvent event) -> { new FadeInLeftTransition(lblWelcome).play(); new FadeInRightTransition(lblRudy).play(); new FadeInTransition(vboxBottom).play(); }); service.setOnSucceeded((WorkerStateEvent event) -> { config2 config = new config2(); config.newStage(stage, lblClose, "/com/toyota/carservice/view/formSwitchMode.fxml", "Aplikasi Informasi Service", true, StageStyle.UNDECORATED, false); }); }
From source file:mesclasses.objects.LoadWindow.java
private void temporize(long millis) { Service<Object> service = new Service() { @Override/*ww w.j a v a 2s . c om*/ protected Task createTask() { return new WaitTask(millis); } }; service.stateProperty().addListener( (ObservableValue<? extends Worker.State> o, Worker.State oldValue, Worker.State newValue) -> { switch (newValue) { case FAILED: case CANCELLED: successful = false; dialogStage.close(); break; case SUCCEEDED: next(); } }); service.start(); }
From source file:de.halirutan.spectralis.examples.sloexporter.Controller.java
public void exportFiles() { File outputDir = showDirectorySelectDialog("Select output directory"); if (!outputDir.canWrite()) { Alert alert = new Alert(AlertType.ERROR, "Cannot write to output directory"); alert.show();//from w w w .jav a 2s.c om } Task<Integer> exportTask = new ExportWorker(outputDir); Service<Integer> service = new Service<Integer>() { @Override protected Task<Integer> createTask() { return exportTask; } }; service.start(); }
From source file:herudi.controller.microMarketController.java
private void selectWithService() { Service<Integer> service = new Service<Integer>() { @Override// www .j a v a 2 s. c om protected Task<Integer> createTask() { selectData(); return new Task<Integer>() { @Override protected Integer call() throws Exception { Integer max = crud.selectData().size(); if (max > 35) { max = 30; } updateProgress(0, max); for (int k = 0; k < max; k++) { Thread.sleep(40); updateProgress(k + 1, max); } return max; } }; } }; service.start(); bar.progressProperty().bind(service.progressProperty()); service.setOnRunning((WorkerStateEvent event) -> { imgLoad.setVisible(true); }); service.setOnSucceeded((WorkerStateEvent event) -> { imgLoad.setVisible(false); new FadeInUpTransition(paneTabel).play(); }); }
From source file:com.jscriptive.moneyfx.ui.chart.ChartFrame.java
/** * This method is invoked when the daily balance button has been toggled * * @param actionEvent/* w w w . ja v a 2s . c o m*/ */ public void dailyBalanceToggled(ActionEvent actionEvent) { LocalDateAxis xAxis = new LocalDateAxis(); NumberAxis yAxis = new NumberAxis(); final LineChart<LocalDate, Number> lineChart = new LineChart<>(xAxis, yAxis); lineChart.setCreateSymbols(false); chartFrame.setCenter(lineChart); ToggleButton toggle = (ToggleButton) actionEvent.getTarget(); if (toggle.isSelected()) { xAxis.setLabel("Day of year"); yAxis.setLabel("Balance in Euro"); lineChart.setTitle("Balance development day by day"); ValueRange<LocalDate> period = getTransactionOpRange(accountCombo.getValue(), yearCombo.getValue()); if (period.isEmpty()) { return; } xAxis.setLowerBound(period.from()); xAxis.setUpperBound(period.to()); Service<Void> service = new Service<Void>() { @Override protected Task<Void> createTask() { return new Task<Void>() { @Override protected Void call() throws Exception { Map<Account, List<Transaction>> transactionMap = getTransactions( accountCombo.getValue(), yearCombo.getValue()); transactionMap.entrySet().forEach(entry -> { Account account = entry.getKey(); List<Transaction> transactionList = entry.getValue(); XYChart.Series<LocalDate, Number> series = new XYChart.Series<>(); series.setName(format("%s [%s]", account.toPresentableString(), account.getFormattedBalance())); // sort transactions by operation value descending transactionList.sort((t1, t2) -> t2.getDtOp().compareTo(t1.getDtOp())); account.calculateStartingBalance(transactionList); series.getData() .add(new XYChart.Data<>(account.getBalanceDate(), account.getBalance())); // sort transactions by operation value ascending transactionList.sort((t1, t2) -> t1.getDtOp().compareTo(t2.getDtOp())); transactionList.forEach(trx -> { account.calculateCurrentBalance(trx); series.getData().add( new XYChart.Data<>(account.getBalanceDate(), account.getBalance())); }); Platform.runLater(() -> lineChart.getData().add(series)); }); return null; } }; } }; service.start(); } }
From source file:herudi.controller.customerController.java
private void displayDiscountCode() { Service<ObservableList<DiscountCode>> service = new Service<ObservableList<DiscountCode>>() { @Override// w w w .j av a2 s . c o m protected Task<ObservableList<DiscountCode>> createTask() { return new Task<ObservableList<DiscountCode>>() { @Override protected ObservableList<DiscountCode> call() throws Exception { ObservableList<DiscountCode> listTask = FXCollections.observableArrayList(); if (listTask == null) { listTask = FXCollections.observableArrayList(crud.selectCode()); } else { listTask.clear(); listTask.addAll(crud.selectCode()); } cbDiscount.setItems(listTask); return listTask; } }; } }; service.start(); }
From source file:herudi.controller.productController.java
private void displayManufacturer() { Service<ObservableList<Manufacturer>> service = new Service<ObservableList<Manufacturer>>() { @Override//from w ww .j a va 2 s .c o m protected Task<ObservableList<Manufacturer>> createTask() { return new Task<ObservableList<Manufacturer>>() { @Override protected ObservableList<Manufacturer> call() throws Exception { ObservableList<Manufacturer> listTask = FXCollections.observableArrayList(); if (listTask == null) { listTask = FXCollections.observableArrayList(crud.selectManufacturerID()); } else { listTask.clear(); listTask.addAll(crud.selectManufacturerID()); } cbManufacturer.setItems(listTask); return listTask; } }; } }; service.start(); }
From source file:herudi.controller.customerController.java
private void displayZip() { Service<ObservableList<MicroMarket>> service = new Service<ObservableList<MicroMarket>>() { @Override/* w ww.j a va 2s . com*/ protected Task<ObservableList<MicroMarket>> createTask() { return new Task<ObservableList<MicroMarket>>() { @Override protected ObservableList<MicroMarket> call() throws Exception { ObservableList<MicroMarket> listTask = FXCollections.observableArrayList(); if (listTask == null) { listTask = FXCollections.observableArrayList(crud.selectZip()); } else { listTask.clear(); listTask.addAll(crud.selectZip()); } cbZip.setItems(listTask); return listTask; } }; } }; service.start(); }
From source file:herudi.controller.productController.java
private void displayProductCode() { Service<ObservableList<ProductCode>> service = new Service<ObservableList<ProductCode>>() { @Override//from w w w . j a v a 2 s .co m protected Task<ObservableList<ProductCode>> createTask() { return new Task<ObservableList<ProductCode>>() { @Override protected ObservableList<ProductCode> call() throws Exception { ObservableList<ProductCode> listTask = FXCollections.observableArrayList(); if (listTask == null) { listTask = FXCollections.observableArrayList(crud.selectProductCode()); } else { listTask.clear(); listTask.addAll(crud.selectProductCode()); } cbProductCode.setItems(listTask); return listTask; } }; } }; service.start(); }