当前位置: 首页>>代码示例>>Java>>正文


Java Service.start方法代码示例

本文整理汇总了Java中javafx.concurrent.Service.start方法的典型用法代码示例。如果您正苦于以下问题:Java Service.start方法的具体用法?Java Service.start怎么用?Java Service.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.concurrent.Service的用法示例。


在下文中一共展示了Service.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: backgroundSearch

import javafx.concurrent.Service; //导入方法依赖的package包/类
private void backgroundSearch(String query){
    if(query != null) {
        if (!GmailMessages.activeSearches.isEmpty()) {
            for (Service<Void> service : GmailMessages.activeSearches) {
                service.cancel();
            }
        }
        Service<Void> search = new Service<Void>() {
            @Override
            protected Task<Void> createTask() {
                try {
                    GmailOperations.listSearchMessages(query);
                    GmailOperations.getSearchMessages(query);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                return null;
            }
        };
        GmailMessages.activeSearches.add(search);
        search.start();
    }
}
 
开发者ID:ashoknailwal,项目名称:desktop-gmail-client,代码行数:24,代码来源:MainUI3Controller.java

示例2: loadFontWeights

import javafx.concurrent.Service; //导入方法依赖的package包/类
/**
 * @작성자 : KYJ
 * @작성일 : 2016. 12. 2.
 */
private void loadFontWeights() {

	Service<List<String>> createFxService = new Service<List<String>>() {
		@Override
		protected Task<List<String>> createTask() {
			return new Task<List<String>>() {
				@Override
				protected List<String> call() throws Exception {
					return FxUtil.FONTUtil.getFontWeights();
				}
			};
		}
	};

	createFxService.setOnSucceeded(w -> {
		List<String> value = createFxService.getValue();
		cbFontWeight.getItems().addAll(value);
	});

	createFxService.start();

}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:27,代码来源:FontViewComposite.java

示例3: loadFontStyles

import javafx.concurrent.Service; //导入方法依赖的package包/类
private void loadFontStyles() {
	Service<List<String>> createFxService = new Service<List<String>>() {
		@Override
		protected Task<List<String>> createTask() {
			return new Task<List<String>>() {
				@Override
				protected List<String> call() throws Exception {
					return FxUtil.FONTUtil.getFontStyles();
				}
			};
		}
	};

	createFxService.setOnSucceeded(w -> {
		List<String> value = createFxService.getValue();
		cbFontStyles.getItems().addAll(value);
	});
	
	

	createFxService.start();

}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:24,代码来源:FontViewComposite.java

示例4: handleDownloadButtonAction

import javafx.concurrent.Service; //导入方法依赖的package包/类
@FXML private void handleDownloadButtonAction(ActionEvent event){
    if(! MainApp.getZdsutils().isAuthenticated()){
        Service<Void> loginTask = handleLoginButtonAction(event);
        loginTask.setOnSucceeded(t -> downloadContents(null));
        loginTask.setOnCancelled(t -> {
            hBottomBox.getChildren().clear();
            Alert alert = new CustomAlert(AlertType.ERROR);
            alert.setTitle(Configuration.getBundle().getString("ui.dialog.auth.failed.title"));
            alert.setHeaderText(Configuration.getBundle().getString("ui.dialog.auth.failed.header"));
            alert.setContentText(Configuration.getBundle().getString("ui.dialog.auth.failed.text"));

            alert.showAndWait();
        });

        loginTask.start();
    }else{
        downloadContents(null);
    }
}
 
开发者ID:firm1,项目名称:zest-writer,代码行数:20,代码来源:MenuController.java

示例5: handleDownloadArticleButtonAction

import javafx.concurrent.Service; //导入方法依赖的package包/类
@FXML private void handleDownloadArticleButtonAction(ActionEvent event){
    if(! MainApp.getZdsutils().isAuthenticated()){
        Service<Void> loginTask = handleLoginButtonAction(event);
        loginTask.setOnSucceeded(t -> downloadContents("ARTICLE"));
        loginTask.setOnCancelled(t -> {
            hBottomBox.getChildren().clear();
            Alert alert = new CustomAlert(AlertType.ERROR);
            alert.setTitle(Configuration.getBundle().getString("ui.dialog.auth.failed.title"));
            alert.setHeaderText(Configuration.getBundle().getString("ui.dialog.auth.failed.header"));
            alert.setContentText(Configuration.getBundle().getString("ui.dialog.auth.failed.text"));

            alert.showAndWait();
        });

        loginTask.start();
    }else{
        downloadContents("ARTICLE");
    }
}
 
开发者ID:firm1,项目名称:zest-writer,代码行数:20,代码来源:MenuController.java

示例6: handleDownloadTutorialButtonAction

import javafx.concurrent.Service; //导入方法依赖的package包/类
@FXML private void handleDownloadTutorialButtonAction(ActionEvent event){
    if(! MainApp.getZdsutils().isAuthenticated()){
        Service<Void> loginTask = handleLoginButtonAction(event);
        loginTask.setOnSucceeded(t -> downloadContents("TUTORIAL"));
        loginTask.setOnCancelled(t -> {
            hBottomBox.getChildren().clear();
            Alert alert = new CustomAlert(AlertType.ERROR);
            alert.setTitle(Configuration.getBundle().getString("ui.dialog.auth.failed.title"));
            alert.setHeaderText(Configuration.getBundle().getString("ui.dialog.auth.failed.header"));
            alert.setContentText(Configuration.getBundle().getString("ui.dialog.auth.failed.text"));

            alert.showAndWait();
        });

        loginTask.start();
    }else{
        downloadContents("TUTORIAL");
    }
}
 
开发者ID:firm1,项目名称:zest-writer,代码行数:20,代码来源:MenuController.java

示例7: handleDownloadOpinionButtonAction

import javafx.concurrent.Service; //导入方法依赖的package包/类
@FXML private void handleDownloadOpinionButtonAction(ActionEvent event){
    if(! MainApp.getZdsutils().isAuthenticated()){
        Service<Void> loginTask = handleLoginButtonAction(event);
        loginTask.setOnSucceeded(t -> downloadContents("OPINION"));
        loginTask.setOnCancelled(t -> {
            hBottomBox.getChildren().clear();
            Alert alert = new CustomAlert(AlertType.ERROR);
            alert.setTitle(Configuration.getBundle().getString("ui.dialog.auth.failed.title"));
            alert.setHeaderText(Configuration.getBundle().getString("ui.dialog.auth.failed.header"));
            alert.setContentText(Configuration.getBundle().getString("ui.dialog.auth.failed.text"));

            alert.showAndWait();
        });

        loginTask.start();
    }else{
        downloadContents("OPINION");
    }
}
 
开发者ID:firm1,项目名称:zest-writer,代码行数:20,代码来源:MenuController.java

示例8: handleUploadButtonAction

import javafx.concurrent.Service; //导入方法依赖的package包/类
@FXML private void handleUploadButtonAction(ActionEvent event){
    if(! MainApp.getZdsutils().isAuthenticated()){
        Service<Void> loginTask = handleLoginButtonAction(event);
        loginTask.setOnCancelled(t -> {
            hBottomBox.getChildren().clear();
            Alert alert = new CustomAlert(AlertType.ERROR);
            alert.setTitle(Configuration.getBundle().getString("ui.dialog.upload.content.failed.title"));
            alert.setHeaderText(Configuration.getBundle().getString("ui.dialog.upload.content.failed.header"));
            alert.setContentText(Configuration.getBundle().getString("ui.dialog.upload.content.failed.text"));

            alert.showAndWait();
        });
        loginTask.setOnSucceeded(t -> uploadContents());
        loginTask.start();
    }else{
        uploadContents();
    }
}
 
开发者ID:firm1,项目名称:zest-writer,代码行数:19,代码来源:MenuController.java

示例9: handleSelectFileAction

import javafx.concurrent.Service; //导入方法依赖的package包/类
@FXML private void handleSelectFileAction(){
    if(! zdsUtils.isAuthenticated()){
        Service<Void> loginTask = menuManager.handleLoginButtonAction(null);
        loginTask.setOnSucceeded(t -> selectAndUploadImage());
        loginTask.setOnCancelled(t -> {
            menuManager.getHBottomBox().getChildren().clear();
            Alert alert = new CustomAlert(AlertType.ERROR);
            alert.setTitle(Configuration.getBundle().getString("ui.dialog.auth.failed.title"));
            alert.setHeaderText(Configuration.getBundle().getString("ui.dialog.auth.failed.header"));
            alert.setContentText(Configuration.getBundle().getString("ui.dialog.auth.failed.text"));

            alert.showAndWait();
        });
        loginTask.start();
    }else{
        selectAndUploadImage();
    }
}
 
开发者ID:firm1,项目名称:zest-writer,代码行数:19,代码来源:ImageInputDialog.java

示例10: removeAllBlocs

import javafx.concurrent.Service; //导入方法依赖的package包/类
public void removeAllBlocs() {

        final Bloc[][] blocs = currentRoundDetails.blocs;

        int maxX = blocs.length;
        int maxY = blocs[0].length;

        final Service<Void> calculateService = new Service<Void>() {

            @Override
            protected Task<Void> createTask() {
                return new Task<Void>() {

                    @Override
                    protected Void call() throws Exception {
                        for (int i = 0; i < maxX; i++) {
                            for (int j = 0; j < maxY; j++) {

                                removeBloc(blocs[i][j]);

                            }
                        }
                        return null;
                    }
                };
            }
        };
        calculateService.start();
    }
 
开发者ID:schwabdidier,项目名称:GazePlay,代码行数:30,代码来源:Blocs.java

示例11: loadFontNames

import javafx.concurrent.Service; //导入方法依赖的package包/类
/**
 * 폰트명 로딩
 * @작성자 : KYJ
 * @작성일 : 2016. 12. 2.
 */
private void loadFontNames() {

	Service<List<String>> createFxService = new Service<List<String>>() {
		@Override
		protected Task<List<String>> createTask() {
			return new Task<List<String>>() {
				@Override
				protected List<String> call() throws Exception {
					List<String> avaliableFontNames = FxUtil.FONTUtil.getAvaliableFontNames();
					return avaliableFontNames;
				}
			};
		}
	};

	createFxService.setOnSucceeded(w -> {
		List<String> value = createFxService.getValue();
		cbFontNames.getItems().addAll(value);
		LOGGER.debug("Font Load Completed.");

		cbFontNames.setDisable(false);
	});
	
	createFxService.setExecutor(newFixedThreadExecutor);
	createFxService.start();

}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:33,代码来源:FontViewComposite.java

示例12: logout

import javafx.concurrent.Service; //导入方法依赖的package包/类
public void logout() {
	Service<Void> service = new Service<Void>() {
		@Override
		protected Task<Void> createTask() {
			return new Task<Void>() {
				@Override
				protected Void call() throws Exception {
					if (logged) {
						try {
							HttpUriRequest request = RequestBuilder.get().setUri("/logout").setConfig(requestConfig)
									.build();
							EntityUtils.toString(
									closeableHttpClient.execute(target, request, httpClientContext).getEntity());
							closeableHttpClient.close();
							cookieStore.clear();
							logged = false;
							Context.setMessage("Wylogowano pomyślnie", "green");
						} catch (Exception ex) {
							Context.setMessage("Wystąpił problem z połączeniem", "red");
						}
					} else {
						Context.setMessage("Nie jesteś zalogowany", "red");
					}
					return null;
				}
			};
		}
	};
	service.start();
}
 
开发者ID:marcin-pwr,项目名称:hotel,代码行数:31,代码来源:ConnectionHelper.java

示例13: handleImport

import javafx.concurrent.Service; //导入方法依赖的package包/类
@FXML
private void handleImport(ActionEvent event) {
    final Service<Attachments> service = importersBox.getValue();
    if (service.isRunning()) {
        service.cancel();
        return;
    }
    service.reset();

    importersBox.disableProperty().bind(service.runningProperty());
    progressBar.visibleProperty().bind(service.runningProperty());
    progressBar.progressProperty().bind(service.progressProperty());
    service.runningProperty().addListener(e -> {
        final String key = service.isRunning() ? "cancel" : "import";
        importButton.setText(resources.getString(key));
    });
    service.setOnFailed(e -> Notification.error(resources.getString("notification.failed")));
    service.setOnSucceeded(e -> {
        Notification.success(resources.getString("notification.completed"));

        final Attachments attachments = service.getValue();
        if (attachments == null) return;

        NoticeController.getNoticeTreeViewController().getCurrentNotice().addAttachments(attachments);
        NoticeController.getNoticeViewController().rebuildAttachsView();
    });
    service.start();
}
 
开发者ID:NoticEditorTeam,项目名称:NoticEditor,代码行数:29,代码来源:AttachmentImportController.java

示例14: handleAction

import javafx.concurrent.Service; //导入方法依赖的package包/类
private void handleAction(ActionEvent ae) {

		// retrieving bean properties may take some time
		// so we have to put it on separate thread to keep UI responsive
		Service<?> service = new Service<ObservableList<Item>>() {

			@Override
			protected Task<ObservableList<Item>> createTask() {
				return new Task<ObservableList<Item>>() {
					@Override
					protected ObservableList<Item> call() throws Exception {
						return bean == null ? null : getProperties(bean);
					}
				};
			}

		};
		service.setOnSucceeded(new EventHandler<WorkerStateEvent>() {

			@SuppressWarnings("unchecked")
			@Override
			public void handle(WorkerStateEvent e) {
				ObservableList<Item> items = (ObservableList<Item>) e.getSource().getValue();
				if (items != null) {
					try {
						propertySheet.getItems().setAll(items.filtered((v) -> v != null));
					} catch (Exception exc) {
						//exc.printStackTrace();
						propertySheet.getItems().clear();
					}
				} else {
					propertySheet.getItems().clear();
				}
			}
		});
		service.start();

	}
 
开发者ID:davidB,项目名称:jme3_ext_spatial_explorer,代码行数:39,代码来源:Explorer0.java

示例15: start

import javafx.concurrent.Service; //导入方法依赖的package包/类
@Override
    public void start(Stage primaryStage) {
        
//        try {
            BorderPane borderPane = new BorderPane();
            Scene scene = new Scene(borderPane, 800, 600);
            StopList.add(hashtag);
            
            /* TWITTER */
//        log=CLogOut.getInstance();
//        log.getMessages().addListener((ov,s,s1)->System.out.println(s1));
            
            final Service service=new Service<Void>(){
                @Override protected Task<Void> createTask() {   
                    Task<Void> task = new Task<Void>(){
                        @Override protected Void call() throws Exception {
                            final List<String> rawParameters = getParameters().getRaw();
                            conf = TwitterOAuth.getInstance(rawParameters.toArray(new String[rawParameters.size()])).readOAuth();
                            return null;
                        }
                    };
                    return task;
                }
            };
            
            service.setOnSucceeded(e->{
                if(!hashtag.isEmpty() && conf!=null){
                    tweetsTask= new TagTweets(conf, hashtag, borderPane);
                    tweetsTask.start();
                }
            });
            
            primaryStage.setTitle("The JavaFX Tweetwall for NetBeans Day!");
//            primaryStage.setTitle("The JavaFX Tweetwall for Devoxx!");
            primaryStage.setScene(scene);
            primaryStage.show();
            primaryStage.setFullScreen(true);
            service.start();
//        } catch (IOException ex) {
//            Logger.getLogger(TagCloud.class.getName()).log(Level.SEVERE, null, ex);
//        }
    }
 
开发者ID:svenreimers,项目名称:TweetwallFX-Legacy,代码行数:43,代码来源:TagCloud.java


注:本文中的javafx.concurrent.Service.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。