List of usage examples for javafx.application Platform exit
public static void exit()
From source file:de.pixida.logtest.designer.MainWindow.java
private boolean handleExitApplication() { final ObservableList<Tab> tabs = this.tabPane.getTabs(); for (final Tab tab : tabs) { this.tabPane.getSelectionModel().select(tab); if (!this.handleCloseTab()) { return false; }/*from w w w. ja v a 2s . c o m*/ } Platform.exit(); return true; }
From source file:com.bekwam.resignator.ResignatorAppMainViewController.java
@FXML public void initialize() { try {/*from ww w . j a v a 2s .c om*/ miHelp.setAccelerator(KeyCombination.keyCombination("F1")); cbType.getItems().add(SigningArgumentsType.JAR); cbType.getItems().add(SigningArgumentsType.FOLDER); cbType.getSelectionModel().select(SigningArgumentsType.JAR); cbType.setConverter(new StringConverter<SigningArgumentsType>() { @Override public String toString(SigningArgumentsType type) { return StringUtils.capitalize(StringUtils.lowerCase(String.valueOf(type))); } @Override public SigningArgumentsType fromString(String type) { return Enum.valueOf(SigningArgumentsType.class, StringUtils.upperCase(type)); } }); activeConfiguration.activeProfileProperty().bindBidirectional(activeProfile.profileNameProperty()); tfSourceFile.textProperty().bindBidirectional(activeProfile.sourceFileFileNameProperty()); tfTargetFile.textProperty().bindBidirectional(activeProfile.targetFileFileNameProperty()); ckReplace.selectedProperty().bindBidirectional(activeProfile.replaceSignaturesProperty()); cbType.valueProperty().bindBidirectional(activeProfile.argsTypeProperty()); miSave.disableProperty().bind(needsSave.not()); tfSourceFile.textProperty().addListener(new WeakInvalidationListener(needsSaveListener)); tfTargetFile.textProperty().addListener(new WeakInvalidationListener(needsSaveListener)); ckReplace.selectedProperty().addListener(new WeakInvalidationListener(needsSaveListener)); cbType.valueProperty().addListener(new WeakInvalidationListener(needsSaveListener)); lblSource.setText(SOURCE_LABEL_JAR); lblTarget.setText(TARGET_LABEL_JAR); cbType.getSelectionModel().selectedItemProperty().addListener((ov, old_v, new_v) -> { if (new_v == SigningArgumentsType.FOLDER) { if (!lblSource.getText().equalsIgnoreCase(SOURCE_LABEL_FOLDER)) { lblSource.setText(SOURCE_LABEL_FOLDER); } if (!lblSource.getText().equalsIgnoreCase(TARGET_LABEL_FOLDER)) { lblTarget.setText(TARGET_LABEL_FOLDER); } } else { if (!lblSource.getText().equalsIgnoreCase(SOURCE_LABEL_JAR)) { lblSource.setText(SOURCE_LABEL_JAR); } if (!lblSource.getText().equalsIgnoreCase(TARGET_LABEL_JAR)) { lblTarget.setText(TARGET_LABEL_JAR); } } }); lvProfiles.getSelectionModel().selectedItemProperty().addListener((ov, old_v, new_v) -> { if (new_v == null) { // coming from clearSelection or sort return; } if (needsSave.getValue()) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "Discard unsaved profile?"); alert.setHeaderText("Unsaved profile"); Optional<ButtonType> response = alert.showAndWait(); if (!response.isPresent() || response.get() != ButtonType.OK) { if (logger.isDebugEnabled()) { logger.debug("[SELECT] discard canceled"); } return; } } if (logger.isDebugEnabled()) { logger.debug("[SELECT] nv={}", new_v); } doLoadProfile(new_v); }); lvProfiles.setCellFactory(TextFieldListCell.forListView()); Task<Void> t = new Task<Void>() { @Override protected Void call() throws Exception { updateMessage("Loading configuration"); configurationDS.loadConfiguration(); if (!configurationDS.isSecured()) { if (logger.isDebugEnabled()) { logger.debug("[CALL] config not secured; getting password"); } NewPasswordController npc = newPasswordControllerProvider.get(); if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] npc id={}", npc.hashCode()); } Platform.runLater(() -> { try { npc.showAndWait(); } catch (Exception exc) { logger.error("error showing npc", exc); } }); synchronized (npc) { try { npc.wait(MAX_WAIT_TIME); // 10 minutes to enter the password } catch (InterruptedException exc) { logger.error("new password operation interrupted", exc); } } if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] npc={}", npc.getHashedPassword()); } if (StringUtils.isNotEmpty(npc.getHashedPassword())) { activeConfiguration.setHashedPassword(npc.getHashedPassword()); activeConfiguration.setUnhashedPassword(npc.getUnhashedPassword()); activeConfiguration.setLastUpdatedDateTime(LocalDateTime.now()); configurationDS.saveConfiguration(); configurationDS.loadConfiguration(); configurationDS.decrypt(activeConfiguration.getUnhashedPassword()); } else { Platform.runLater(() -> { Alert noPassword = new Alert(Alert.AlertType.INFORMATION, "You'll need to provide a password to save your keystore credentials."); noPassword.showAndWait(); }); return null; } } else { PasswordController pc = passwordControllerProvider.get(); Platform.runLater(() -> { try { pc.showAndWait(); } catch (Exception exc) { logger.error("error showing pc", exc); } }); synchronized (pc) { try { pc.wait(MAX_WAIT_TIME); // 10 minutes to enter the password } catch (InterruptedException exc) { logger.error("password operation interrupted", exc); } } Platform.runLater(() -> { if (pc.getStage().isShowing()) { // ended in timeout timeout pc.getStage().hide(); } if (pc.wasCancelled() || pc.wasReset() || !pc.doesPasswordMatch()) { if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] was cancelled or the number of retries was exceeded"); } String msg = ""; if (pc.wasCancelled()) { msg = "You must provide a password to the datastore. Exitting..."; } else if (pc.wasReset()) { msg = "Data file removed. Exitting..."; } else { msg = "Exceeded maximum number of retries. Exitting..."; } Alert alert = new Alert(Alert.AlertType.WARNING, msg); alert.setOnCloseRequest((evt) -> { Platform.exit(); System.exit(1); }); alert.showAndWait(); } else { // // save password for later decryption ops // activeConfiguration.setUnhashedPassword(pc.getPassword()); configurationDS.decrypt(activeConfiguration.getUnhashedPassword()); // // init profileBrowser // if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] loading profiles from source"); } long startTimeMillis = System.currentTimeMillis(); final List<String> profileNames = configurationDS.getProfiles().stream() .map(Profile::getProfileName).sorted((o1, o2) -> o1.compareToIgnoreCase(o2)) .collect(Collectors.toList()); final List<String> recentProfiles = configurationDS.getRecentProfileNames(); if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] loading profiles into UI"); } lvProfiles.setItems(FXCollections.observableArrayList(profileNames)); if (CollectionUtils.isNotEmpty(recentProfiles)) { mRecentProfiles.getItems().clear(); mRecentProfiles.getItems().addAll( FXCollections.observableArrayList(recentProfiles.stream().map((s) -> { MenuItem mi = new MenuItem(s); mi.setOnAction(recentProfileLoadHandler); return mi; }).collect(Collectors.toList()))); } // // #31 preload the last active profile // if (StringUtils.isNotEmpty(activeConfiguration.getActiveProfile())) { if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] preloading last active profile={}", activeConfiguration.getActiveProfile()); } doLoadProfile(activeConfiguration.getActiveProfile()); } long endTimeMillis = System.currentTimeMillis(); if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] loading profiles took {} ms", (endTimeMillis - startTimeMillis)); } } }); } return null; } @Override protected void succeeded() { super.succeeded(); updateMessage(""); lblStatus.textProperty().unbind(); } @Override protected void cancelled() { super.cancelled(); logger.error("task cancelled", getException()); updateMessage(""); lblStatus.textProperty().unbind(); } @Override protected void failed() { super.failed(); logger.error("task failed", getException()); updateMessage(""); lblStatus.textProperty().unbind(); } }; lblStatus.textProperty().bind(t.messageProperty()); new Thread(t).start(); } catch (Exception exc) { logger.error("can't load configuration", exc); String msg = "Verify that the user has access to the directory '" + configFile + "' under " + System.getProperty("user.home") + "."; Alert alert = new Alert(Alert.AlertType.ERROR, msg); alert.setHeaderText("Can't load config file"); alert.showAndWait(); Platform.exit(); } }
From source file:org.noroomattheinn.visibletesla.MainController.java
@FXML void closeHandler(ActionEvent event) { Platform.exit(); }
From source file:view.FXApplicationController.java
@Override public void initialize(URL arg0, ResourceBundle arg1) { System.out.println("initialize called"); overlay3.addEventHandler(MouseEvent.ANY, new EventHandler<MouseEvent>() { @Override/*from w w w .j av a 2 s . c om*/ public void handle(MouseEvent mouse) { mouseX.set(mouse.getX()); mouseY.set(mouse.getY()); if (kComplexFlag) { if (mouse.getEventType() == MouseEvent.MOUSE_PRESSED) { Line line = new Line(); line.setStyle("-fx-stroke: red;"); overlay3.getChildren().add(line); line.setStartX(0); line.setStartY(0); line.setLayoutX(mouseX.get()); line.setLayoutY(mouseY.get()); lines.add(line); } if (mouse.isPrimaryButtonDown() && (!lines.isEmpty())) { Line line = lines.getLast(); double endXPos = mouseX.get() - line.getLayoutX(); double endYPos = mouseY.get() - line.getLayoutY(); line.setEndX(endXPos); line.setEndY(endYPos); calculatePercentageKComplex(); } } if (help1Flag) { double offsetSize = 1. / (activeChannels.size() + 1.); double posOnOverlay = mouse.getY(); double zoom = 1.0; for (int i = 0; i < activeChannels.size(); i++) { double realOffset = (1 - (i + 1.) * offsetSize); double upperBound = yAxis.getDisplayPosition( (realOffset - offsetSize / 2.) * yAxis.getUpperBound()) + yAxis.getLayoutY(); double lowerBound = yAxis.getDisplayPosition( (realOffset + offsetSize / 2.) * yAxis.getUpperBound()) + yAxis.getLayoutY(); if ((posOnOverlay <= upperBound) && (posOnOverlay > lowerBound)) { zoom = getZoomFromChannel(activeChannels.get(i)); } } space.set(75.0 * zoom / yAxis.getUpperBound() * yAxis.getHeight()); line1.setVisible(true); line2.setVisible(true); } else { line1.setVisible(false); line2.setVisible(false); } } }); //Key Listener lineChart.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent ke) { keyAction(ke); } }); toolBarGoto.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent ke) { if (ke.getCode() == KeyCode.ENTER) { int valueTextField = -1; try { valueTextField = Integer.parseInt(toolBarGoto.getText()); } catch (NumberFormatException e) { toolBarGoto.setText((currentEpoch + 1) + ""); valueTextField = currentEpoch + 1; Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Error during handling enter key.", e); } if (valueTextField > dataModel.getNumberOf30sEpochs()) { valueTextField = dataModel.getNumberOf30sEpochs(); } else if (valueTextField < 1) { valueTextField = 1; } currentEpoch = valueTextField - 1; goToEpoch(currentEpoch); if (kComplexFlag) { calculatePercentageKComplex(); } } } }); choiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { System.out.println(newValue); if (newValue != null) { featureModel.setFeatureChannel(Arrays.asList(channelNames).indexOf(newValue)); System.out.println("########" + Arrays.asList(channelNames).indexOf(newValue)); System.out.println(featureModel.getFeatureChannel()); featureModel.setTsneComputed(false); featureModel.setFeaturesComputed(false); featureModel.setClassificationDone(false); featureModel.setReadinDone(false); classifyButton.setDisable(false); recompute = true; if (viewModel.isKcMarkersActive()) { computeKCfeatures(); } else { overlay4.getChildren().clear(); } } } }); choiceBoxModel.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { classifier = classifierList.get(newValue.intValue()); System.out.println(classifier); featureModel.setClassificationDone(false); featureModel.setReadinDone(false); classifyButton.setDisable(false); recompute = true; } }); primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { System.out.println("RandomAccessFile closed"); dataModel.getReader().close(); Platform.exit(); } }); kComplexOnAction(); help1OnAction(); }
From source file:Main.java
private VBox getTransformationControls() { xSlider.setShowTickMarks(true);/* w ww .jav a2s. com*/ xSlider.setShowTickLabels(true); xSlider.snapToTicksProperty().set(true); ySlider.setShowTickMarks(true); ySlider.setShowTickLabels(true); ySlider.snapToTicksProperty().set(true); widthSlider.setShowTickMarks(true); widthSlider.setShowTickLabels(true); widthSlider.snapToTicksProperty().set(true); heightSlider.setShowTickMarks(true); heightSlider.setShowTickLabels(true); heightSlider.snapToTicksProperty().set(true); opacitySlider.setShowTickMarks(true); opacitySlider.setShowTickLabels(true); opacitySlider.snapToTicksProperty().set(true); opacitySlider.setMinorTickCount(5); opacitySlider.setMajorTickUnit(0.20d); strokeSlider.setShowTickMarks(true); strokeSlider.setShowTickLabels(true); strokeSlider.snapToTicksProperty().set(true); strokeSlider.setMinorTickCount(5); strokeSlider.setMajorTickUnit(1.0d); translateXSlider.setShowTickMarks(true); translateXSlider.setShowTickLabels(true); translateXSlider.snapToTicksProperty().set(true); translateYSlider.setShowTickMarks(true); translateYSlider.setShowTickLabels(true); translateYSlider.snapToTicksProperty().set(true); rotateSlider.setShowTickMarks(true); rotateSlider.setShowTickLabels(true); rotateSlider.snapToTicksProperty().set(true); rotateSlider.setMinorTickCount(5); rotateSlider.setMajorTickUnit(30.0); scaleXSlider.setShowTickMarks(true); scaleXSlider.setShowTickLabels(true); scaleXSlider.setMajorTickUnit(0.2d); scaleXSlider.setLabelFormatter(new DoubleStringConverter()); scaleXSlider.snapToTicksProperty().set(true); scaleYSlider.setShowTickMarks(true); scaleYSlider.setShowTickLabels(true); scaleYSlider.setMajorTickUnit(0.2d); scaleYSlider.setLabelFormatter(new DoubleStringConverter()); scaleYSlider.snapToTicksProperty().set(true); shearXSlider.setShowTickMarks(true); shearXSlider.setShowTickLabels(true); shearXSlider.setMajorTickUnit(0.2d); shearXSlider.setLabelFormatter(new DoubleStringConverter()); shearXSlider.snapToTicksProperty().set(true); shearYSlider.setShowTickMarks(true); shearYSlider.setShowTickLabels(true); shearYSlider.setMajorTickUnit(0.2d); shearYSlider.setLabelFormatter(new DoubleStringConverter()); shearYSlider.snapToTicksProperty().set(true); HBox xyBox = new HBox(); xyBox.setSpacing(5); xyBox.getChildren().addAll(VBoxBuilder.create().children(xLabel, xSlider).build(), VBoxBuilder.create().children(yLabel, ySlider).build()); HBox whBox = new HBox(); whBox.setSpacing(5); whBox.getChildren().addAll(VBoxBuilder.create().children(widthLabel, widthSlider).build(), VBoxBuilder.create().children(heightLabel, heightSlider).build()); HBox colorBox = new HBox(); colorBox.setSpacing(5); colorBox.getChildren().addAll(VBoxBuilder.create().children(strokeLabel, strokeSlider).build(), VBoxBuilder.create().children(new Label("Stroke Color"), rectStrokeColorChoiceBox).build()); HBox opacityBox = new HBox(); opacityBox.setSpacing(5); opacityBox.getChildren().addAll(VBoxBuilder.create().children(opacityLabel, opacitySlider).build(), VBoxBuilder.create().children(new Label("Fill Color"), rectFillColorChoiceBox).build()); HBox translateBox = new HBox(); translateBox.setSpacing(5); translateBox.getChildren().addAll(VBoxBuilder.create().children(translateXLabel, translateXSlider).build(), VBoxBuilder.create().children(translateYLabel, translateYSlider).build()); HBox rotateBox = new HBox(); rotateBox.setSpacing(5); rotateBox.getChildren().addAll(VBoxBuilder.create().children(rotateLabel, rotateSlider).build()); HBox scaleBox = new HBox(); scaleBox.setSpacing(5); scaleBox.getChildren().addAll(VBoxBuilder.create().children(scaleXLabel, scaleXSlider).build(), VBoxBuilder.create().children(scaleYLabel, scaleYSlider).build()); HBox shearBox = new HBox(); shearBox.setSpacing(5); shearBox.getChildren().addAll(VBoxBuilder.create().children(shearXLabel, shearXSlider).build(), VBoxBuilder.create().children(shearYLabel, shearYSlider).build()); VBox rectangleBox = new VBox(); rectangleBox.getChildren().addAll(xyBox, whBox, colorBox, opacityBox); TitledPane rectangleProps = new TitledPane("Rectangle", rectangleBox); VBox transformBox = new VBox(); transformBox.getChildren().addAll(translateBox, rotateBox, scaleBox, shearBox); TitledPane transformsProps = new TitledPane("Tranformations", transformBox); TitledPane showBoundsControls = getShowBoundsControls(); TitledPane effectPane = getEffectTitledPane(); Button resetAllButton = new Button("Reset All"); resetAllButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { resetAll(); } }); Button saveButton = new Button("Save Layout as Image"); saveButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { saveLayoutAsImage(); } }); Button exitButton = new Button("Exit"); exitButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { Platform.exit(); } }); /* Button printButton = new Button("Print"); printButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { String str = getDesc("layoutBounds", mainRect.getLayoutBounds()) + getDesc("\nboundsInLocal", mainRect.getBoundsInLocal()) + getDesc("\nboundsInParent", mainRect.getBoundsInParent()); //printDataTextArea.setText(str); } private String getDesc(String type, Bounds b) { String str = type + "[minX=" + b.getMinX() + ", minY=" + b.getMinY() + ", width=" + b.getWidth() + ", height=" + b.getHeight() + "]"; return str; } }); */ HBox buttonBox = new HBox(); buttonBox.setSpacing(10); buttonBox.getChildren().addAll(resetAllButton, saveButton, exitButton); VBox vBox = new VBox(); vBox.getChildren().addAll(buttonBox, showBoundsControls, rectangleProps, effectPane, transformsProps); return vBox; }
From source file:nl.mvdr.umvc3replayanalyser.controller.Umvc3ReplayManagerController.java
/** Action handler which exits the application. */ @FXML/*from w ww . j ava 2 s .co m*/ private void handleExitAction() { log.info("Close menu item selected; stopping the application."); Platform.exit(); }
From source file:org.ykc.usbcx.MainWindowController.java
public void setStage(Stage stage) { myStage = stage;/* ww w. j a v a 2 s .c om*/ myStage.setOnCloseRequest(new EventHandler<WindowEvent>() { public void handle(WindowEvent we) { appClosing(); usbcontrol.terminate(); cordinator.terminate(); try { Thread.sleep(50); } catch (InterruptedException e) { } Platform.exit(); System.exit(0); } }); }
From source file:acmi.l2.clientmod.xdat.Controller.java
@FXML private void exit() { Platform.exit(); }
From source file:org.noroomattheinn.visibletesla.MainController.java
private void exitWithMobileAccessError() { Platform.runLater(new Runnable() { @Override/* www . j a va 2s . c o m*/ public void run() { Dialogs.showErrorDialog(app.stage, "Your Tesla has not been configured to allow mobile " + "access. You have to enable this on your car's touch" + "screen using Controls / Settings / Vehicle." + "\n\nChange that setting in your car, then relaunch VisibleTesla.", "Unable to communicate with your Tesla", "Communication Problem"); logger.log(Level.SEVERE, "Mobile access is not enabled - exiting."); Platform.exit(); } }); }
From source file:org.noroomattheinn.visibletesla.MainController.java
private void exitWithCachingError() { Platform.runLater(new Runnable() { @Override/* w w w . j av a 2 s. c o m*/ public void run() { Dialogs.showErrorDialog(app.stage, "Failed to connect to your vehicle even after a successful " + "login. It may be in a deep sleep and can't be woken up.\n" + "\nPlease try to wake your Tesla and then try VisibleTesla again.", "Unable to communicate with your Tesla", "Communication Problem"); logger.severe("Can't communicate with vehicle - exiting."); Platform.exit(); } }); }