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


Java Service类代码示例

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


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

示例1: ServerListMainTreeItem

import javafx.concurrent.Service; //导入依赖的package包/类
public ServerListMainTreeItem() {
	super("Servers");
	setGraphic(new ImageView(icon));

	new Service<List<Server>>() {
		@Override
		protected Task<List<Server>> createTask() {
			return new SsTask<List<Server>>() {
				@Override
				protected List<Server> call() throws Exception {
					return getServerRegistry().getServers();
				}

				@Override
				protected void succeeded() {
					final List<Server> servers;
					try { servers = get(); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(e); }
					addTreeItemsViewCallback(servers);
					super.succeeded();
				}
			};
		}
	}.start();
}
 
开发者ID:subshare,项目名称:subshare,代码行数:25,代码来源:ServerListMainTreeItem.java

示例2: 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

示例3: transitToConnectedMode

import javafx.concurrent.Service; //导入依赖的package包/类
private void transitToConnectedMode() {
    if(mode == Mode.REMOTE){
        CDH.setPort(Mode.getPort(mode));
    }
    
    System.out.println("ConnectionManager.State -> "+c.getState().toString());
    if(c.getState() == Service.State.CANCELLED || c.getState() == Service.State.SUCCEEDED){
        Platform.runLater(() ->{
           reinitSession();
        });
    }

    if(c.getState() == Service.State.READY){
        Log.log("FXMLController","attempting to init ConnectionManager");
        initSession();
    }
    TIME_STARTED_LABEL.setText("Time started: "+new SimpleDateFormat("HH:mm:ss").format(new Date()));
    TIME_STOPPED_LABEL.setText("Time stopped: ");
    CONNECT.setDisable(true);
    DISCONNECT.setDisable(false);
}
 
开发者ID:Obsidiam,项目名称:amelia,代码行数:22,代码来源:MainViewController.java

示例4: 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

示例5: 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

示例6: handleLoginButtonAction

import javafx.concurrent.Service; //导入依赖的package包/类
@FXML public Service<Void> handleLoginButtonAction(ActionEvent event){
    // Button for google
    Button googleAuth = new Button(Configuration.getBundle().getString("ui.dialog.auth.google.title"), IconFactory.createGoogleIcon());
    LoginDialog dialog = new LoginDialog(googleAuth);
    googleAuth.setOnAction(t -> {
        GoogleLoginDialog googleDialog = new GoogleLoginDialog(dialog);
        googleDialog.show();
    });
    Optional<Pair<String, String>> result = dialog.showAndWait();

    hBottomBox.add(labelField, 0, 0);
    LoginService loginTask = new LoginService();
    result.ifPresent(usernamePassword -> {
        loginTask.setUsername(usernamePassword.getKey());
        loginTask.setPassword(usernamePassword.getValue());
    });
    labelField.textProperty().bind(loginTask.messageProperty());
    return loginTask;
}
 
开发者ID:firm1,项目名称:zest-writer,代码行数:20,代码来源:MenuController.java

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: startServer

import javafx.concurrent.Service; //导入依赖的package包/类
private void startServer(int port) throws Exception {
    new Service<Void>() {

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

                @Override
                protected Void call() throws Exception {
                    new Server().connect(resetButton, connectionStatusLabel,
                            messageLabel, port);
                    return null;
                }
                
            };
        }
        
    }.start();
}
 
开发者ID:varunon9,项目名称:Remote-Control-PC,代码行数:20,代码来源:MainScreenController.java

示例14: connect

import javafx.concurrent.Service; //导入依赖的package包/类
public void connect(InetAddress inetAddress, int port) {
    new Service<Void>() {

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

                @Override
                protected Void call() throws Exception {
                    Thread.sleep(3000);
                    connectToAndroid(inetAddress, port);
                    return null;
                }
                
            };
        }
        
    }.start();
}
 
开发者ID:varunon9,项目名称:Remote-Control-PC,代码行数:20,代码来源:ClientToAndroid.java

示例15: initRunningService

import javafx.concurrent.Service; //导入依赖的package包/类
private void initRunningService(final BooleanSupplier autoAdjustResolution, final Runnable updateUI) {
    runningService = new Service<Void>() {

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

                @Override
                protected Void call() throws Exception {
                    looper.start(autoAdjustResolution, updateUI);
                    return null;
                }
            };
        }
    };
    runningService.setOnCancelled(event -> {
        runningService.reset();
        logger.warning("Running is cancelled");
    });
    runningService.setOnFailed(event -> {
        runningService.reset();
        logger.warning("Running is failed");
    });
}
 
开发者ID:paspiz85,项目名称:nanobot,代码行数:25,代码来源:Model.java


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