private void save(DSSDocument signedDocument) { FileChooser fileChooser = new FileChooser(); fileChooser.setInitialFileName(signedDocument.getName()); MimeType mimeType = signedDocument.getMimeType(); ExtensionFilter extFilter = new ExtensionFilter(mimeType.getMimeTypeString(), "*." + MimeType.getExtension(mimeType)); fileChooser.getExtensionFilters().add(extFilter); File fileToSave = fileChooser.showSaveDialog(stage); if (fileToSave != null) { try { FileOutputStream fos = new FileOutputStream(fileToSave); Utils.copy(signedDocument.openStream(), fos); Utils.closeQuietly(fos); } catch (Exception e) { Alert alert = new Alert(AlertType.ERROR, "Unable to save file : " + e.getMessage(), ButtonType.CLOSE); alert.showAndWait(); return; } } }
public static void displayDeleteGameAlert() { int index = -1; Alert alert = new Alert(AlertType.CONFIRMATION); alert.setHeaderText(null); alert.setContentText("Are you sure you want to delete the selected games?"); ButtonType deleteGame = new ButtonType("Delete Game(s)"); ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(deleteGame, buttonTypeCancel); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == deleteGame){ for (String g : selectedGamesString) { index = getGameIndex(g); gameList.getGameList().remove(index); } refreshGameList(); deleteButton.setDisable(true); } else { // ... user chose CANCEL or closed the dialog } }
/** * Process the transaction when a student check-out a book. * @param event The even that triggered this function. * @throws IOException IOException In case a file cannot be loaded. * @throws SQLException The even that triggered this function */ @FXML public void processCheckOutButtonPressed(ActionEvent event) throws IOException, SQLException { BooksIssued transaction = new BooksIssued(Long.valueOf(isbnCheckOutTF.getText()), Integer.valueOf(iDCheckOutTF.getText())); int success = transaction.processCheckOutTransaction(); if(success == 1){ displayAlert(Alert.AlertType.INFORMATION,"Receipt" , ("Transaction ID: " + transaction.getTransID() + "\n\nStudent ID: " + transaction.getCardID() + "\nIssue Date: " + transaction.getIssueDate() + "\nDue Date: " + transaction.getDueDate()), "1"); Books book = new Books(Long.valueOf(isbnCheckOutTF.getText()), Integer.valueOf(copiesCheckOutTF.getText())); book.decreasedCopies(); clearCheckOutForm(); resultsTableView.getItems().clear(); //clear table data to show new one. } else{ displayAlert(Alert.AlertType.WARNING,"Error" , ("Error adding student"), "6"); } }
private void removeMemberAction(Event e) { MemberView selected = memberTable.selectionModelProperty().get().getSelectedItem(); if (selected != null) { Alert conf = new Alert(AlertType.CONFIRMATION, "Do you really want to transfert " + organization.getName() + "'s ownership to "+ selected.getUsername() + " ?\n"); Optional<ButtonType> result = conf.showAndWait(); if (result.isPresent() && result.get().equals(ButtonType.OK)) { try { organization.removeMember(selected.getId()); } catch (JSONException | WebApiException | IOException | HttpException e1) { ErrorUtils.getAlertFromException(e1).show(); forceUpdateMemberList(); e1.printStackTrace(); } } } }
private void transferOwnershipAction(Event e) { MemberView selected = memberTable.selectionModelProperty().get().getSelectedItem(); if (selected != null) { Alert conf = ErrorUtils.newAlert(AlertType.CONFIRMATION, "Transfer ownership confirmation", "Do you really want to transfer " + organization.getName() + "'s ownership to "+ selected.getUsername() + " ?", "This action is definitive, be careful."); Optional<ButtonType> result = conf.showAndWait(); if (result.isPresent() && result.get().equals(ButtonType.OK)) { try { organization.transfertOwnership(selected.getId()); eos.close(); } catch (JSONException | WebApiException | IOException | HttpException e1) { ErrorUtils.getAlertFromException(e1).show(); e1.printStackTrace(); } } } }
private void removeAction(Event e) { Alert conf = new Alert(AlertType.CONFIRMATION, "Do you really want to delete this organization ?\n" + "Every server and member association will be lost."); Optional<ButtonType> result = conf.showAndWait(); if (result.isPresent() && result.get().equals(ButtonType.OK)) { try { wsp.removeOrganization(orgas.selectionModelProperty().get().getSelectedItem().getOrganization()); forceOrganizationListRefresh(); App.getCurrentInstance().refreshWSPTabs(); } catch(Exception e1) { ErrorUtils.getAlertFromException(e1).show(); } } }
private void editWSPAction(Event e) { EditWSPDialog dialog = new EditWSPDialog(wsp); Optional<WebServiceProvider> result = dialog.showAndWait(); if (result.isPresent()) { try { wsp = result.get(); wsp.fetchConfiguration(); writeWSP(wsp); } catch (JSONException | WebApiException | IOException | HttpException e1) { Alert a = ErrorUtils.getAlertFromException(e1); a.show(); e1.printStackTrace(); } } else { new Alert(AlertType.ERROR, "Wrong WSP information"); } }
@FXML private void mnuUndo(ActionEvent event) { Stage CashCalculateStage = (Stage) btnSignOut.getScene().getWindow(); Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Action Failed"); alert.setHeaderText("Undo Function Works Only From \"Make A Transaction\" and \"History\" Window"); alert.setContentText("Press \"OK\" to go to \"Make A Transaction\" window"); alert.setX(CashCalculateStage.getX() + 60); alert.setY(CashCalculateStage.getY() + 170); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK){ (new TabAccess()).setTabName("tabGetMoney"); //name of which Tab should open (new GoToOperation()).goToMakeATransaction(CashCalculateStage.getX(), CashCalculateStage.getY()); CashCalculateStage.close(); } }
@FXML private void mnuUndo(ActionEvent event) { Stage SettingsStage = (Stage) btnSignOut.getScene().getWindow(); Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Action Failed"); alert.setHeaderText("Undo Function Works Only From \"Make A Transaction\" and \"History\" Window"); alert.setContentText("Press \"OK\" to go to \"Make A Transaction\" window"); alert.setX(SettingsStage.getX() + 60); alert.setY(SettingsStage.getY() + 170); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK){ (new TabAccess()).setTabName("tabGetMoney"); //name of which Tab should open (new GoToOperation()).goToMakeATransaction(SettingsStage.getX(), SettingsStage.getY()); SettingsStage.close(); } }
public void changeLocaleAndReload(String locale){ saveCurrentProject(); Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Confirmation Dialog"); alert.setHeaderText("This will take effect after reboot"); alert.setContentText("Are you ok with this?"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK){ // ... user chose OK try { Properties props = new Properties(); props.setProperty("locale", locale); File f = new File(getClass().getResource("../bundles/Current.properties").getFile()); OutputStream out = new FileOutputStream( f ); props.store(out, "This is an optional header comment string"); start(primaryStage); } catch (Exception e ) { e.printStackTrace(); } } else { // ... user chose CANCEL or closed the dialog } }
@FXML private void unarchiveSector(ActionEvent event) { try { sector.unarchiveSector(sectorcmboUnArchive.getValue()); Alert confirmationMsg = new Alert(AlertType.INFORMATION); confirmationMsg.setTitle("Message"); confirmationMsg.setHeaderText(null); confirmationMsg.setContentText(sectorcmboUnArchive.getValue()+ " is Unarchived Successfully"); Stage SettingsStage = (Stage) btnDashboard.getScene().getWindow(); confirmationMsg.setX(SettingsStage.getX() + 200); confirmationMsg.setY(SettingsStage.getY() + 170); confirmationMsg.showAndWait(); tabSectorInitialize(); } catch (Exception e) {} }
@FXML private void mnuUndo(ActionEvent event) { Stage DashboardStage = (Stage) btnSignOut.getScene().getWindow(); Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Action Failed"); alert.setHeaderText("Undo Function Works Only From \"Make A Transaction\" and \"History\" Window"); alert.setContentText("Press \"OK\" to go to \"Make A Transaction\" window"); alert.setX(DashboardStage.getX() + 60); alert.setY(DashboardStage.getY() + 170); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK){ (new TabAccess()).setTabName("tabGetMoney"); //name of which Tab should open (new GoToOperation()).goToMakeATransaction(DashboardStage.getX(), DashboardStage.getY()); DashboardStage.close(); } }
public int alertErrorConfirm() { int r = 0; Alert alert = new Alert(AlertType.ERROR); alert.setTitle("경고"); alert.setHeaderText(null); alert.setContentText(this.msg); alert.showAndWait(); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { r = 1; } return r; }
@FXML private void handleDeleteEntry() { int selectedIndex = entryTable.getSelectionModel().getSelectedIndex(); if (selectedIndex >= 0) { entryTable.getItems().remove(selectedIndex); } else { Alert alert = new Alert(AlertType.WARNING); alert.initOwner(mainApp.getPrimaryStage()); alert.setTitle("No Selection"); alert.setHeaderText("No Entry Selected"); alert.setContentText("Please select an entry in the table"); alert.showAndWait(); } }
private void saveMatches() { Path path = Gui.requestFile("Save matches file", gui.getScene().getWindow(), Arrays.asList(new FileChooser.ExtensionFilter("Matches", "*.match")), false); if (path == null) return; if (!path.getFileName().toString().toLowerCase(Locale.ENGLISH).endsWith(".match")) { path = path.resolveSibling(path.getFileName().toString()+".match"); } try { if (Files.isDirectory(path)) { gui.showAlert(AlertType.ERROR, "Save error", "Invalid file selection", "The selected file is a directory."); } else if (Files.exists(path)) { Files.deleteIfExists(path); } if (!gui.getMatcher().saveMatches(path)) { gui.showAlert(AlertType.WARNING, "Matches save warning", "No matches to save", "There are currently no matched classes, so saving was aborted."); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); return; } }
@FXML public void presentNewGameProposalWindow(Event e) { TextInputDialog dialog = new TextInputDialog(); dialog.setHeaderText("Neuer Spielvorschalg"); dialog.setContentText("Wie soll das Spiel heissen?"); Optional<String> gameNameResult = dialog.showAndWait(); gameNameResult.ifPresent(result -> { if (!gameNameResult.get().isEmpty()) { this.client.enqueueTask(new CommunicationTask(new ClientMessage("server", "newgame", gameNameResult.get()), (success, response) -> { Platform.runLater(() -> { if (success && response.getDomain().equals("success") && response.getCommand().equals("created")) { refreshGameList(e); System.out.println("Game erstellt"); } else { Alert alert = new Alert(AlertType.ERROR); alert.setHeaderText("Das Spiel konnte nicht erstellt werden"); alert.setContentText(response.toString()); alert.show(); } }); })); } }); }
private void senhaInvalida() { if (txtLogin.getText().equals("") && !pswSenha.getText().equals("")) { caixaAlerta(AlertType.ERROR, "Erro ao fazer login", "Login deve ser informado", "Informe o login!"); } if (pswSenha.getText().equals("") && !txtLogin.getText().equals("")) { caixaAlerta(AlertType.ERROR, "Erro ao fazer login", "Senha deve ser informada", "Informe a senha!"); } if (txtLogin.getText().equals("") && pswSenha.getText().equals("")) { caixaAlerta(AlertType.ERROR, "Erro ao fazer login", "Login e senha devem ser informados", "Informe o login e a senha!"); } if (!txtLogin.getText().equals("") && !pswSenha.getText().equals("")) { caixaAlerta(AlertType.ERROR, "Erro ao fazer login", "Login e senha inv�lidos", "Informe login e senha v�lidos!"); } }
private boolean closeEditor(IEditor e) { if (e == null) { return true; } if (e.isDirty()) { Optional<ButtonType> result = FXUIUtils.showConfirmDialog(DisplayWindow.this, "File \"" + e.getName() + "\" Modified. Do you want to save the changes ", "File \"" + e.getName() + "\" Modified", AlertType.CONFIRMATION, ButtonType.YES, ButtonType.NO, ButtonType.CANCEL); ButtonType shouldSaveFile = result.get(); if (shouldSaveFile == ButtonType.CANCEL) { return false; } if (shouldSaveFile == ButtonType.YES) { File file = save(e); if (file == null) { return false; } EditorDockable dockable = (EditorDockable) e.getData("dockable"); dockable.updateKey(); } } return true; }
public boolean canAppend(File file) { EditorDockable dockable = findEditorDockable(file); if (dockable == null) { return true; } if (!dockable.getEditor().isDirty()) { return true; } Optional<ButtonType> result = FXUIUtils.showConfirmDialog(DisplayWindow.this, "File " + file.getName() + " being edited. Do you want to save the file?", "Save Module", AlertType.CONFIRMATION, ButtonType.YES, ButtonType.NO); ButtonType option = result.get(); if (option == ButtonType.YES) { save(dockable.getEditor()); return true; } return false; }
@FXML void btnProximo_onAction(ActionEvent event) { String string = getDadosTabVisualizar(); if (string.length() > 0) { Alert alerta = new Alert(AlertType.INFORMATION); alerta.setTitle("AlphaLab"); alerta.setHeaderText("Dados de Requisitos"); alerta.setContentText(string); alerta.show(); } else { tabVisualizar.setDisable(true); tabPreencherDados.setDisable(false); tbpDados.getSelectionModel().select(tabPreencherDados); texLaboratorio.setText(cmbLaboratorio.getValue().getNome()); if (hbxHorarios.getChildren() != null) hbxHorarios.getChildren().clear(); criarNovasReservas(); hbxHorarios.getChildren().addAll(buildBoxHorario()); cmbProfessor.requestFocus(); } }
public static void showMessageDialog(Window parent, String message, String title, AlertType type, boolean monospace) { if (Platform.isFxApplicationThread()) { _showMessageDialog(parent, message, title, type, monospace); } else { Object lock = new Object(); synchronized (lock) { Platform.runLater(() -> { _showMessageDialog(parent, message, title, type, monospace); lock.notifyAll(); }); } synchronized (lock) { try { lock.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } } }
public static void _showMessageDialog(Window parent, String message, String title, AlertType type, boolean monospace) { Alert alert = new Alert(type); alert.initOwner(parent); alert.setTitle(title); alert.setHeaderText(title); alert.setContentText(message); alert.initModality(Modality.APPLICATION_MODAL); alert.setResizable(true); if (monospace) { Text text = new Text(message); alert.getDialogPane().setStyle("-fx-padding: 0 10px 0 10px;"); text.setStyle(" -fx-font-family: monospace;"); alert.getDialogPane().contentProperty().set(text); } alert.showAndWait(); }
@FXML private void handleEditEntry() throws Exception { Entry selectedEntry = entryTable.getSelectionModel().getSelectedItem(); if (selectedEntry != null) { boolean okClicked = mainApp.showAppEditDialog(selectedEntry); if (okClicked) { // removed description field } } else { Alert alert = new Alert(AlertType.WARNING); alert.initOwner(mainApp.getPrimaryStage()); alert.setTitle("No Selection"); alert.setHeaderText("No Entry Selected"); alert.setContentText("Please select an entry in the table."); alert.showAndWait(); } }
@Override protected void humanActions(Player p) { try { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("ActionsFXML.fxml")); Parent root1 = (Parent) fxmlLoader.load(); ActionsFXMLController actionCtrl = fxmlLoader.getController(); actionCtrl.setPlayer(p); actionCtrl.setBackground(background); Stage stage = new Stage(); stage.initModality(Modality.APPLICATION_MODAL); //Pour click sur close de action stage.setOnCloseRequest((WindowEvent event) -> { // consume event event.consume(); // show close dialog Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Pas de précipitation !"); alert.setHeaderText(null); alert.setContentText("Vous devez choisir 6 actions !\nNe pas oublier de choisir la région pour les délégations."); alert.showAndWait(); }); stage.setTitle("Choix des actions"); stage.setScene(new Scene(root1)); stage.showAndWait(); } catch (IOException ex) { Logger.getLogger(PlayGraphic.class.getName()).log(Level.SEVERE, null, ex); } }
/** * Display an option Alert to verify user selection. * @param message The message to be displayed at the window. * @return an <code>integer</code> specifying if user wants to proceed or not. */ public int optionsAlert(String message){ Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Delete permanetly"); alert.setHeaderText(null); alert.setContentText(message); ButtonType button1 = new ButtonType("Yes"); ButtonType button2 = new ButtonType("No"); alert.getButtonTypes().setAll(button2, button1); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == button1) return 1; //1 == delete else return 0; //0 == don't delete }
public static void showPropertyContainerEditor(Window owner, KlcPropertyContainer propertyContainer, String title, String headerText, String contentText) { Alert alert = new Alert(AlertType.CONFIRMATION, contentText, ButtonType.OK); alert.setTitle(title); alert.setHeaderText(headerText); alert.initOwner(owner); alert.initModality(Modality.WINDOW_MODAL); KlcPropertyContainerEditor editor = new KlcPropertyContainerEditor(); editor.setPrefWidth(300); editor.setPrefHeight(200); editor.setPropertyContainer(propertyContainer); alert.getDialogPane().setContent(editor); alert.showAndWait(); }
@Override public Optional<ButtonType> delete(Optional<ButtonType> option) { if (!option.isPresent() || option.get() != FXUIUtils.YES_ALL) { option = FXUIUtils.showConfirmDialog(null, "Do you want to delete the folder `" + path + "` and all its children?", "Confirm", AlertType.CONFIRMATION, ButtonType.YES, ButtonType.NO, FXUIUtils.YES_ALL, ButtonType.CANCEL); } if (option.isPresent() && (option.get() == ButtonType.YES || option.get() == FXUIUtils.YES_ALL)) { if (Files.exists(path)) { try { File file = path.toFile(); File[] listFiles = file.listFiles(); option = Copy.delete(path, option); if (listFiles.length > 0) for (File f : listFiles) { Event.fireEvent(this, new ResourceModificationEvent(ResourceModificationEvent.DELETE, new FileResource(f))); } Event.fireEvent(this, new ResourceModificationEvent(ResourceModificationEvent.DELETE, this)); getParent().getChildren().remove(this); } catch (IOException e) { String message = String.format("Unable to delete: %s: %s%n", path, e); FXUIUtils.showMessageDialog(null, message, "Unable to delete", AlertType.ERROR); } } } return option; }
/** * Given a directory key like marathon.test.dir check whether given * directory exists. * * @param dirKey * , a property key * @return true, if the directory exists */ private static boolean dirExists(String dirKey, boolean batchMode) { String dirName = System.getProperty(dirKey); if (dirKey != null) { dirName = dirName.replace(';', File.pathSeparatorChar); dirName = dirName.replace('/', File.separatorChar); System.setProperty(dirKey, dirName); } dirName = System.getProperty(dirKey); String[] values = dirName.split(String.valueOf(File.pathSeparatorChar)); for (String value : values) { File dir = new File(value); if (!dir.exists() || !dir.isDirectory()) { if (batchMode) System.err.println("Invalid directory specified for " + dirKey + " - " + dirName); else FXUIUtils.showMessageDialog(null, "Invalid directory specified for " + dirKey + " - " + dirName, "Error", AlertType.ERROR); return false; } } return true; }
public void deleteInterview(DescriptionEntretien interview){ Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Supression Entretien"); alert.setHeaderText("Vous allez supprimer "+interview.getNom()); ButtonType buttonTypeOne = new ButtonType("Valider"); ButtonType buttonTypeCancel = new ButtonType("Annuler", ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(buttonTypeOne, buttonTypeCancel); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == buttonTypeOne){ main.getCurrentProject().getEntretiens().remove(interview); this.getTreeItem().getParent().getChildren().remove(this.getTreeItem()); } }
@FXML private void handleNew() { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Confirmation Dialog"); alert.setHeaderText("Do you want to save your current changes?"); alert.setContentText(""); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK){ File entryFile = mainApp.getFilePath(); mainApp.saveEntryDataToFile(entryFile); } mainApp.getEntryList().clear(); mainApp.setFilePath(null); }
/** * Spawns an error dialogue detailing the given exception. * <p> * The given message will be used as the dialogue's header, and the exception's stack * trace will appear in the hidden "more information" dropdown. * <p> * If the exception has a message, it will be displayed in the dialogue's content * field, prefaced by "Cause:" * * @param exception * The exception to display * @param message * A message to describe the context of the dialogue, usually why the * dialogue is appearing (e.g. "An error has occurred!") */ public static void showAlertDialogue(Exception exception, String message) { String context = exception.getMessage(); boolean valid = (context != null && !context.isEmpty()); context = (valid) ? "Cause: " + context : null; Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Exception Dialog"); alert.setHeaderText(message); alert.setContentText(context); alert.setGraphic(null); String exceptionText = getStackTraceAsString(exception); TextArea textArea = new TextArea(exceptionText); textArea.setEditable(false); textArea.setWrapText(false); alert.getDialogPane().setExpandableContent(textArea); alert.showAndWait(); }
private void sendNewMessage() { Optional<String> result = SendMessageDialogController.showAndWait(conversation.get()); if (result.isPresent()) { Conversation conv = conversation.get(); Message message = new Message(); message.setThreadId(conv.getThreadId()); message.setAddress(conv.getParticipant()); message.setBody(result.get()); message.setMine(true); if (cs.sendMessage(message)) { conv.getMessages().add(message); messages.add(message); } else { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Error"); alert.setHeaderText("An error occured while sending the message."); alert.showAndWait(); } } }
public void renameImage(String path,String file_to_rename) { TextInputDialog input = new TextInputDialog(file_to_rename.substring(0, file_to_rename.length()-4)+"1"+file_to_rename.substring(file_to_rename.length()-4)); Optional<String> change = input.showAndWait(); change.ifPresent((String change_event) -> { try { Files.move(new File(path).toPath(),new File(new File(path).getParent()+File.separator+change_event).toPath()); } catch (IOException ex) { Alert a = new Alert(AlertType.ERROR); a.setTitle("Rename"); a.setHeaderText("Error while renaming the file."); a.setContentText("Error code: "+e.getErrorInfo(ex)+"\n"+e.getErrorMessage(ex)); a.showAndWait(); } }); System.gc(); }
/** * Create and display an alert to the user. * * @param message * string to display to user. */ private void displayAlert(String message) { Alert infoAlert = new Alert(AlertType.WARNING); infoAlert.setTitle(null); infoAlert.setHeaderText(null); infoAlert.setContentText(message); infoAlert.showAndWait(); }
public static void displayEditGameAlert() { int index = getGameIndex(selectedGamesString.get(0)); ArrayList<Game> tempGameList = (ArrayList<Game>) gameList.getGameList().clone(); Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("" + tempGameList.get(index).getName()); alert.setHeaderText(null); alert.setContentText("Would you like to edit the game " + tempGameList.get(index).getName() + "?"); ButtonType editGame = new ButtonType("Edit Game"); ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(editGame, buttonTypeCancel); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == editGame) { NewGameWindow newGameWindow = new NewGameWindow(tempGameList.get(index) ); Game newGame = newGameWindow.showAndAddGame(); if (newGame != null) { // Add title to game list gameList.getGameList().remove(index); gameList.addGame(newGame); refreshGameList(); editButton.setDisable(true); deleteButton.setDisable(true); } } else { // ... user chose CANCEL or closed the dialog } }
private void showNoMoreRoomsInCategoryErrorDialog() { Alert errorDialog = new Alert(Alert.AlertType.ERROR); errorDialog.setTitle("Error"); errorDialog.setHeaderText("Error Placing Booking"); errorDialog.setContentText("We were unable to place your booking because there" + " were not enough rooms of the type you requested available. " + "This can happen if somebody else booked the rooms you were trying to" + " before you completed your booking." + "\n Please return to the previous screen and try again."); errorDialog.showAndWait(); }
@FXML void saveImage() { if (image == null) { Alert a = new Alert(AlertType.ERROR); a.setContentText("No image to export!"); a.show(); } FileChooser fileChooser = new FileChooser(); fileChooser.setInitialDirectory(Preferences.getPath("lastImageDir").toFile()); fileChooser.setTitle("Save image"); fileChooser.getExtensionFilters().addAll( new ExtensionFilter("PNG Images", "*.png")); File selected = fileChooser.showSaveDialog(getScene().getWindow()); if (selected != null) { Preferences.setPath("lastImageDir", selected.toPath()); try { ImageIO.write(image.toBufferedImage(), "png", selected); } catch (IOException e) { logger.error("Error while saving the image.", e); ExceptionDialog exceptionDialog = new ExceptionDialog(e); exceptionDialog.setTitle("Error"); exceptionDialog.setHeaderText("Error while saving the image."); exceptionDialog.show(); } } }
@FXML public void validationButtonClick(Event evt) { boolean allGood = true; int count = 0; while (count < 6 && allGood == true) { ComboBox action = choiceBoxes.get(count); if (action.getValue() != null) { if (action.getValue().equals("Delegation")) { ComboBox region = regionBoxes.get(count); if (region.getValue() == null) { allGood = false; } } } else { allGood = false; } count++; } if (allGood) { validateAndClose(evt); } else { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Pas de précipitation !"); alert.setHeaderText(null); alert.setContentText("Vous devez choisir 6 actions !\nNe pas oublier de choisir la région pour les délégations."); alert.showAndWait(); } }
private void editServerAction(Event e) { ServerView selectedServer = serverTable.selectionModelProperty().get().getSelectedItem(); if (selectedServer == null) { new Alert(AlertType.ERROR, "No selected server.").show(); return; } EditServerDialog dialog = new EditServerDialog(new LocalServer(selectedServer.getName(), selectedServer.getServer().getAddress(), selectedServer.getServer().getPort(), "")); Optional<LocalServer> result = dialog.showAndWait(); if (result.isPresent()) { try { organization.editServer(selectedServer.getServer().getServerId(), result.get()); oms.forceOrganizationListRefresh(); forceUpdateServerList(); App.getCurrentInstance().refreshWSPTabs(); serverTable.refresh(); } catch(Exception e1) { ErrorUtils.getAlertFromException(e1).show(); } } }