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 handleCloseTab() { final Editor currentEditor = this.getCurrentEditor(); if (!currentEditor.hasUnsavedChanges()) { return true; }/*from ww w .j a va 2 s . c om*/ final Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle("Confirm close"); alert.setHeaderText("If the " + currentEditor.getTypeName() + " \"" + currentEditor.getTitleShort().get() + "\" is not saved, all changes are lost."); alert.setContentText("Do you want to save the " + currentEditor.getTypeName() + "?"); final ButtonType yes = new ButtonType("Yes"); final ButtonType no = new ButtonType("No"); final ButtonType cancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(yes, no, cancel); final Optional<ButtonType> choice = alert.showAndWait(); if (choice.get() == yes) { // Continue with saving if (!this.handleSaveDocument()) { return false; } } else if (choice.get() == no) { // Dispose document } else { // User closed dialog or chose cancel return false; } return true; }
From source file:se.trixon.mapollage.ui.MainApp.java
private void profileEdit(Profile profile) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.initOwner(mStage);/*from w ww .ja v a 2s .c om*/ 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(); } else if (clone) { title = Dict.CLONE.toString(); profile.setLastRun(0); } alert.setTitle(title); alert.setGraphic(null); alert.setHeaderText(null); alert.setResizable(true); 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 void showValidationEditor(String column) { validationEditorController.setSelectedColumn(column); validationEditorController.updateForm(); Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setGraphic(null);/* ww w . j a va 2s . c o m*/ alert.setTitle(resourceBundle.getString("dialog.validation.rules.title")); alert.setHeaderText(format(resourceBundle.getString("dialog.validation.rules.header"), column)); alert.getDialogPane().setContent(validationEditorController.getView()); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { runLater(() -> { validationEditorController.updateConfiguration(); currentCsvFile.setFileChanged(true); currentCsvFile.getContent().revalidate(column); }); } }
From source file:hd3gtv.as5kpc.Serverchannel.java
void appRec(TextField mediaid, int _take, TextField showname) { int _id;//from w w w . ja v a 2 s .c o m try { _id = Integer.parseInt(mediaid.getText()); } catch (Exception e) { Alert alert = new Alert(AlertType.WARNING); alert.setTitle("Media ID"); alert.setHeaderText("Erreur lors de la rcupration de l'ID, seuls des chiffres sont autoriss."); alert.setContentText("Dtail: " + e.getMessage()); alert.showAndWait(); return; } if (independant_channel) { _id += getVtrIndex(); } RecBackgound rec = createRecBackgound(makeValidId(_id, _take), makeName(getServerLabel(), showname)); rec.start(); }
From source file:net.rptools.tokentool.controller.ManageOverlays_Controller.java
@FXML void restoreButton_onAction(ActionEvent event) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle(I18N.getString("ManageOverlays.dialog.restore.overlays.title")); alert.setContentText(I18N.getString("ManageOverlays.dialog.restore.overlays.content_text")); Optional<ButtonType> result = alert.showAndWait(); if ((result.isPresent()) && (result.get() == ButtonType.OK)) { log.info("Restoring default images..."); try {//from w w w . j a v a 2 s . co m AppSetup.installDefaultOverlays(); } catch (IOException e) { log.error("Error restoring default overlays!", e); } displayTreeView(); } }
From source file:calendarioSeries.vistas.MainViewController.java
@FXML public void handleAbout() { Alert about = new Alert(AlertType.INFORMATION); about.initStyle(StageStyle.UTILITY); about.setTitle("About"); about.setHeaderText("Calendario Series v1.1"); about.setContentText("Creado por Miguel Coleto." + "\nThe MIT License (MIT) Copyright (c) 2016 " + "\nhttps://github.com/Cotel/CalendarioSeries"); about.showAndWait();/* w w w. java 2 s. c o m*/ }
From source file:investiagenofx2.view.InvestiaGenOFXController.java
@FXML void handleBtnAccounts(ActionEvent event) { ArrayList<Account> accountsToGen = new ArrayList<>(); if ("Tous les comptes".equals(cbo_accounts.getSelectionModel().getSelectedItem())) { accountsToGen = accounts;/* w ww . j a v a 2s. c om*/ } else { accountsToGen.add(accounts.get(cbo_accounts.getSelectionModel().getSelectedIndex())); } getTransactionsFromWeb(); String fileName = ""; try { fileName = genOFXFile(accountsToGen); } catch (MyOwnException ex) { Logger.getLogger(InvestiaGenOFXController.class.getName()).log(Level.SEVERE, null, ex); } Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("Confirmation "); alert.setHeaderText(null); alert.setX(InvestiaGenOFX.getPrimaryStage().getX() + 100); alert.setY(InvestiaGenOFX.getPrimaryStage().getY() + 100); alert.setContentText("Fichier OFX gnr \rLance le fichier OFX?"); ButtonType buttonTypeYes = new ButtonType("Oui"); ButtonType buttonTypeNo = new ButtonType("Non"); alert.getButtonTypes().setAll(buttonTypeYes, buttonTypeNo); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == buttonTypeYes) { try { Utilities.launchFile(fileName); } catch (IOException ex) { Logger.getLogger(InvestiaGenOFXController.class.getName()).log(Level.SEVERE, null, ex); } new File(fileName).deleteOnExit(); } showAcountsInvestments(accountsToGen); }
From source file:com.helegris.szorengeteg.ui.forms.TopicFormView.java
private void alertFileNotFound(Exception ex, File file) { Alert alert = new Alert(Alert.AlertType.WARNING); alert.setTitle(Messages.msg("alert.file_upload_unsuccessful")); alert.setHeaderText(Messages.msg("alert.file_not_available")); alert.setContentText(Messages.msg("alert.file") + file.getAbsolutePath()); alert.initModality(Modality.APPLICATION_MODAL); alert.showAndWait();//from ww w. j a va2 s . co m }
From source file:com.mycompany.trafficimportfileconverter2.Main2Controller.java
private void autoSearch() { new Thread(() -> { File[] files = filechooser.getInitialDirectory().listFiles(new FileFilter() { @Override// w ww.j av a2 s. c o m public boolean accept(File pathname) { String x = FilenameUtils.getExtension(pathname.getAbsolutePath()); return x.compareToIgnoreCase("tsv") == 0; } }); File mostRecent = Arrays.stream(files).max((x, y) -> Long.compare(x.lastModified(), y.lastModified())) .orElse(null); if (mostRecent == null) { return; } Platform.runLater(() -> { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setContentText("We found the following TSV file in your default location:\n\"" + mostRecent.getName() + "\"\n" + "Modified: " + new Date(mostRecent.lastModified()) + "\n\n" + "Would you like load this file?"); Optional<ButtonType> answer = alert.showAndWait(); if (answer.isPresent() && answer.get().getButtonData().equals(ButtonData.OK_DONE)) { System.out.println(answer.get()); setInputFile(mostRecent); //setting the input file is enough to trigger the load! // loadInInfo(mostRecent); //not safe, just load the file in for you. // onBtnGo(null); } else { } }); }).start(); }
From source file:com.properned.application.SystemController.java
public ButtonType askForSave() { logger.info("Save alert open"); Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle(MessageReader.getInstance().getMessage("popup.confirmation.warning")); alert.setHeaderText(MessageReader.getInstance().getMessage("popup.confirmation.close.title")); alert.setContentText(MessageReader.getInstance().getMessage("popup.confirmation.close.body")); ButtonType buttonTypeYes = new ButtonType(MessageReader.getInstance().getMessage("yes")); ButtonType buttonTypeNo = new ButtonType(MessageReader.getInstance().getMessage("no")); ButtonType buttonTypeCancel = new ButtonType("cancel", ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(buttonTypeYes, buttonTypeNo, buttonTypeCancel); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == buttonTypeYes) { logger.info("the user want to save current files"); this.save(); } else if (result.get() == buttonTypeNo) { // Nothing to do here logger.info("the user doesn't want to save current files"); } else {//from ww w. j a v a 2 s . c om logger.info("Properned close cancelled"); } return result.get(); }