當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。