List of usage examples for javafx.scene.control Alert Alert
public Alert(@NamedArg("alertType") AlertType alertType)
From source file:de.pixida.logtest.designer.MainWindow.java
private boolean handleSaveDocumentAs() { final FileChooser fileChooser = this.createFileDialog(this.getCurrentEditor().getType(), "Save"); final File selectedFile = fileChooser.showSaveDialog(this.primaryStage); if (selectedFile == null) { return false; } else {/*from ww w . j a v a 2 s . c om*/ this.applyFolderOfSelectedFileInOpenOrSaveAsFileDialog(selectedFile); boolean overwriteIfPresent = true; final Tab openedDocument = this.findTabThatIsAssignedToFile(selectedFile); if (openedDocument != null) { final Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Confirm overwrite"); alert.setHeaderText("The file is already opened."); alert.setContentText("Do you want to overwrite the file?"); final Optional<ButtonType> choice = alert.showAndWait(); if (choice.get() != ButtonType.OK) { overwriteIfPresent = false; } } if (overwriteIfPresent) { this.getCurrentEditor().assignDocumentToFile(selectedFile); return this.saveDocument(); } else { return false; } } }
From source file:be.makercafe.apps.makerbench.editors.JFXMillEditor.java
private void handleExportAsPngFile(ActionEvent e) { if (millObject == null) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Oeps an error occured"); alert.setHeaderText("Cannot export PNG. There is no geometry !"); alert.setContentText("Please verify that your code generates a valid CSG object."); alert.showAndWait();//w w w.j a v a2s . c om return; } FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Export PNG File"); fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Image files (*.png)", "*.png")); File f = fileChooser.showSaveDialog(null); if (f == null) { return; } String fName = f.getAbsolutePath(); if (!fName.toLowerCase().endsWith(".png")) { fName += ".png"; } int snWidth = 1024; int snHeight = 1024; double realWidth = viewGroup.getBoundsInLocal().getWidth(); double realHeight = viewGroup.getBoundsInLocal().getHeight(); double scaleX = snWidth / realWidth; double scaleY = snHeight / realHeight; double scale = Math.min(scaleX, scaleY); PerspectiveCamera snCam = new PerspectiveCamera(false); snCam.setTranslateZ(-200); SnapshotParameters snapshotParameters = new SnapshotParameters(); snapshotParameters.setTransform(new Scale(scale, scale)); snapshotParameters.setCamera(snCam); snapshotParameters.setDepthBuffer(true); snapshotParameters.setFill(Color.TRANSPARENT); WritableImage snapshot = new WritableImage(snWidth, (int) (realHeight * scale)); viewGroup.snapshot(snapshotParameters, snapshot); try { ImageIO.write(SwingFXUtils.fromFXImage(snapshot, null), "png", new File(fName)); } catch (IOException ex) { Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex); Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Oeps an error occured"); alert.setHeaderText("Cannot export PNG. There went something wrong writing the file."); alert.setContentText( "Please verify that your file is not read only, is not locked by other user or program, you have enough diskspace."); alert.showAndWait(); } }
From source file:be.makercafe.apps.makerbench.editors.GCodeEditor.java
private void handleSaveButton(ActionEvent event) { System.out.println("Event: " + event.getSource()); @SuppressWarnings("unchecked") Map<String, String> map = (Map<String, String>) this.getTab().getUserData(); String path = map.get("path"); try {/*from w w w . jav a 2 s . com*/ FileUtils.writeStringToFile(new File(path), caCodeArea.getText()); } catch (IOException e) { Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Unable to save file."); Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Oeps an error occured"); alert.setHeaderText("Cannot save file. There went something wrong writing the file."); alert.setContentText( "Please verify that your file is not read only, is not locked by other user or program, you have enough diskspace."); alert.showAndWait(); } }
From source file:com.helegris.szorengeteg.ui.forms.TopicFormView.java
/** * Form submission event handler./*from w ww . j av a 2 s .c o m*/ * * @param event */ private void submitTopic(ActionEvent event) { if ("".equals(txtName.getText())) { Alert alert = new Alert(Alert.AlertType.WARNING); alert.setTitle(Messages.msg("alert.missing_data")); alert.setHeaderText(Messages.msg("alert.define_name_for_topic")); alert.initModality(Modality.APPLICATION_MODAL); alert.showAndWait(); return; } try { prepareTopic(); setOrdinals(); getTransactionDone(); VistaNavigator.getMainView().loadContentTopics(); } catch (FileNotFoundException ex) { alertFileNotFound(ex, imageFile); } catch (IOException ex) { new ExceptionAlert(ex).showAndWait(); } catch (MissingDataException ex) { alertMissingData(); } catch (NotFoundException ex) { alertFileNotFound(ex, ex.getFile()); } }
From source file:com.mycompany.trafficimportfileconverter2.Main2Controller.java
@FXML private void onBtnGo(ActionEvent event) { if (null == outputDir.getValue()) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setContentText("Select Output Directory!"); alert.showAndWait();//from w w w . j av a 2s.c o m return; } if (null == inputFile.getValue()) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setContentText("Select Input File!"); alert.showAndWait(); return; } //threadedHandledFileConversion(getInputFile()); handleFileWriting(); if (null == myThread || !myThread.isAlive()) { myThread = (new Thread(() -> { try { watchForConsumption(); } catch (IOException ex) { Logger.getLogger(Main2Controller.class.getName()).log(Level.SEVERE, null, ex); } })); myThread.setDaemon(true); myThread.start(); } }
From source file:ui.main.MainViewController.java
private void sendMessageSC() { if (currentChat == null) { return;//ww w .ja v a 2 s.com } try { ItemType type = contactsManager.getUserType(currentChat.getParticipant()); if (type.equals(ItemType.none)) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("Attention!"); alert.setHeaderText("The user is not available for you!"); alert.setContentText( "The user has not accepted the Friend Request." + " The user is not available for you."); alert.showAndWait(); return; } else if (type.equals(ItemType.from)) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("Attention!"); alert.setHeaderText("An unaccepted user!"); alert.setContentText("You have not accepted the Friend Request." + " You can not send any messages until you accept the friend request."); alert.showAndWait(); return; } else if (type.equals(ItemType.to)) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("Attention!"); alert.setHeaderText("The user has not accepted!"); alert.setContentText("The user has not accepted the Friend Request." + " You can not send any messages until the user accepts the friend request."); alert.showAndWait(); return; } if (message.getText().isEmpty()) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("IMP"); alert.setHeaderText("Message is empty!"); alert.setContentText("You can not send empty messages."); alert.showAndWait(); return; } try { currentChat.sendMessage(message.getText()); //sends message if (history.isSelected()) { DBSingleChat.saveTextMessage(currentChat.getParticipant(), false, message.getText(), new Timestamp(System.currentTimeMillis())); } paintSendMessage(message.getText().trim(), dtfT.print(DateTime.now())); //paints the sent item message.setText(""); //clears the sent text Task tt = new Task() { @Override protected Object call() throws Exception { Thread.sleep(500); return new Object(); } }; tt.setOnSucceeded(value -> scrollPane.setVvalue(scrollPane.getHmax())); Thread thread1 = new Thread(tt); thread1.start(); } catch (XMPPException ex) { Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex); } } catch (NullPointerException e) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("IMP"); alert.setHeaderText("User is unavailable!"); alert.setContentText("The user is unavailable for you!."); alert.showAndWait(); return; } }
From source file:be.makercafe.apps.makerbench.editors.GCodeEditor.java
private void handleExportAsStlFile(ActionEvent e) { if (csgObject == null) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Oeps an error occured"); alert.setHeaderText("Cannot export STL. There is no geometry !"); alert.setContentText("Please verify that your code generates a valid CSG object."); alert.showAndWait();//from ww w . j av a2 s. com return; } FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Export STL File"); fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("STL files (*.stl)", "*.stl")); File f = fileChooser.showSaveDialog(null); if (f == null) { return; } String fName = f.getAbsolutePath(); if (!fName.toLowerCase().endsWith(".stl")) { fName += ".stl"; } try { eu.mihosoft.vrl.v3d.FileUtil.write(Paths.get(fName), csgObject.toStlString()); } catch (IOException ex) { Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex); Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Oeps an error occured"); alert.setHeaderText("Cannot export STL. There went something wrong writing the file."); alert.setContentText( "Please verify that your file is not read only, is not locked by other user or program, you have enough diskspace."); alert.showAndWait(); } }
From source file:de.bayern.gdi.gui.Controller.java
/** * Handler to close the application./* w ww . j a va2 s. c o m*/ * * @param event The event. */ @FXML protected void handleCloseApp(ActionEvent event) { Alert closeDialog = new Alert(Alert.AlertType.CONFIRMATION); closeDialog.setTitle(I18n.getMsg("gui.confirm-exit")); closeDialog.setContentText(I18n.getMsg("gui.want-to-quit")); ButtonType confirm = new ButtonType(I18n.getMsg("gui.exit")); ButtonType cancel = new ButtonType(I18n.getMsg("gui.cancel"), ButtonData.CANCEL_CLOSE); closeDialog.getButtonTypes().setAll(confirm, cancel); Optional<ButtonType> res = closeDialog.showAndWait(); if (res.isPresent() && res.get() == confirm) { logToAppLog(I18n.format("dlc.stop")); Stage stage = (Stage) buttonClose.getScene().getWindow(); stage.fireEvent(new WindowEvent(stage, WindowEvent.WINDOW_CLOSE_REQUEST)); } }
From source file:se.trixon.filebydate.ui.MainApp.java
private void profileEdit(Profile profile) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.initOwner(mStage);//from w ww . j a v a2 s . c o m String title = Dict.EDIT.toString(); boolean addNew = false; boolean clone = profile != null && profile.getName() == null; if (profile == null) { title = Dict.ADD.toString(); addNew = true; profile = new Profile(); profile.setSourceDir(FileUtils.getUserDirectory()); profile.setDestDir(FileUtils.getUserDirectory()); profile.setFilePattern("{*.jpg,*.JPG}"); profile.setDatePattern("yyyy/MM/yyyy-MM-dd"); profile.setOperation(0); profile.setFollowLinks(true); profile.setRecursive(true); profile.setReplaceExisting(false); profile.setCaseBase(NameCase.UNCHANGED); profile.setCaseExt(NameCase.UNCHANGED); } else if (clone) { title = Dict.CLONE.toString(); profile.setLastRun(0); } alert.setTitle(title); alert.setGraphic(null); alert.setHeaderText(null); ProfilePanel profilePanel = new ProfilePanel(profile); final DialogPane dialogPane = alert.getDialogPane(); dialogPane.setContent(profilePanel); profilePanel.setOkButton((Button) dialogPane.lookupButton(ButtonType.OK)); Optional<ButtonType> result = FxHelper.showAndWait(alert, mStage); if (result.get() == ButtonType.OK) { profilePanel.save(); if (addNew || clone) { mProfiles.add(profile); } profilesSave(); populateProfiles(profile); } }
From source file:ninja.javafx.smartcsv.fx.SmartCSVController.java
public boolean canExit() { boolean canExit = true; if (currentCsvFile.getContent() != null && currentCsvFile.isFileChanged()) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle(resourceBundle.getString("dialog.exit.title")); alert.setHeaderText(resourceBundle.getString("dialog.exit.header.text")); alert.setContentText(resourceBundle.getString("dialog.exit.text")); Optional<ButtonType> result = alert.showAndWait(); if (result.get() != ButtonType.OK) { canExit = false;/*from w w w . j ava 2s . com*/ } } return canExit; }