List of usage examples for javafx.scene.control TextInputDialog TextInputDialog
public TextInputDialog(@NamedArg("defaultValue") String defaultValue)
From source file:gallerydemo.menu.ManagementMenuController.java
public ManagementMenuController(GalleryDemoViewController controller) { super(controller, "ManagementMenu.fxml"); this.actualizeButtons(); this.newGalleryButton.setOnAction((ActionEvent event) -> { this.createGalleryOrFolder(true); });//ww w . j a va 2 s . c om this.newFolderButton.setOnAction((ActionEvent event) -> { this.createGalleryOrFolder(false); }); this.galleryPropertiesButton.setOnAction((ActionEvent event) -> { GalleryNode g = this.controller.getActiveGallery(); if (g.isTrunk()) { return; } TextInputDialog dialog = new TextInputDialog(g.getName()); dialog.setTitle("Umbenennen"); dialog.setHeaderText( g.isGallery() ? "Die ausgewhlte Galerie umbenennen" : "Den ausgewhlten Ordner umbenennen"); dialog.setContentText("Neuer Name:"); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { g.setName(result.get()); g.saveConfigFile(); } }); this.deleteGalleryButton.setOnAction((ActionEvent event) -> { GalleryNode g = this.controller.getActiveGallery(); if (g.isTrunk()) { return; } Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Lschen"); alert.setHeaderText( g.isGallery() ? "Die ausgewhlte Galerie lschen?" : "Den ausgewhlten Ordner lschen?"); alert.setContentText("Unwiederruflicher Vorgang!"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { GalleryNode parent = (GalleryNode) g.getParent(); Logger.getLogger("logfile").log(Level.INFO, "[delete] {0}", g.getLocation()); try { FileUtils.deleteDirectory(g.getLocation()); } catch (IOException ex) { Logger.getLogger("logfile").log(Level.SEVERE, null, ex); } finally { // Remove deleted gallery from tree view parent.getChildren().remove(g); this.controller.setActiveGallery(parent); } } }); }
From source file:gallerydemo.menu.ManagementMenuController.java
private void createGalleryOrFolder(boolean isGallery) { GalleryNode g = this.controller.getActiveGallery(); File base;/*from www. j a v a2 s . c o m*/ if (g == null) { base = this.controller.settings.getLocalGalleryLocation(); } // Create outside gallery folder else if (g.isGallery()) { base = g.getLocation().getParentFile(); } // Create insode collection folder else { base = g.getLocation(); } TextInputDialog dialog = new TextInputDialog(isGallery ? "Neue Galerie" : "Neuer Ordner"); dialog.setTitle(isGallery ? "Neue Galerie erstellen" : "Neuen Ordner erstellen"); dialog.setHeaderText(isGallery ? "Bitte geben Sie den Namen der neuen Galerie ein" : "Bitte geben Sie den Namen des neuen Ordners ein"); dialog.setContentText("Name: "); this.controller.disableInput(isGallery ? "Galerie wird erstellt...\nBitte einen Namen eingeben." : "Ordner wird erstellt...\nBitte einen Namen eingeben."); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { File newFolder = new File(base.getAbsolutePath() + "/" + result.get()); newFolder.mkdir(); System.out.println("mkdir " + newFolder.getPath()); if (isGallery) { GalleryNode newGallery = new GalleryNode( new File(newFolder.getAbsolutePath() + "/" + GalleryManager.GALLERY_CONFIG_FILE_NAME), false, true, result.get(), false); newGallery.saveConfigFile(); } else { GalleryNode newGallery = new GalleryNode( new File(newFolder.getAbsolutePath() + "/" + GalleryManager.COLLECTION_CONFIG_FILE_NAME), false, true, result.get(), false); newGallery.saveConfigFile(); } this.controller.refreshTreeItems(); if (g != null) g.setExpanded(true); } this.controller.enableInput(); }
From source file:com.git.ifly6.IRPController.java
@FXML private void initialize() { out = new IRPFormatter(outPane); out.comment("Welcome to ifly Region Protection"); out.comment("Version " + version); try {/*from w ww . j a v a 2 s . c o m*/ IRPConfigReader reader = new IRPConfigReader(configurationFile); IRPConfigKeys keys = reader.getKeys(); regionName = keys.getRegion(); delegate = keys.getDelegate(); founder = keys.getFounder(); anticoupEnabled.setSelected(keys.isAnticoup()); heuristicsEnabled.setSelected(keys.isHeuristics()); networkEnabled.setSelected(keys.isNetwork()); endorsementCap = keys.getCapAmount(); Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle("IRP Alert"); alert.setHeaderText("Scanning"); alert.setContentText("ifly Region Protection is now scanning your region for endorsement counts."); alert.showAndWait(); } catch (FileNotFoundException e) { out.log("Error. Configuration file not found. Please provide configuration file."); String newRegion = ""; TextInputDialog dialog = new TextInputDialog("Region name"); dialog.setTitle("IRP Settings"); dialog.setHeaderText("Change Region"); dialog.setContentText("Enter the region name here:"); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { newRegion = result.get(); } boolean exists = false; try { exists = new NSRegion(newRegion).exists(); } catch (IOException e1) { out.log("ERROR. Cannot confirm region existence."); } if (!newRegion.equals("") && exists) { regionName = newRegion; try { IRPConfigWriter configWriter = new IRPConfigWriter(regionName); configWriter.setAnticoup(true); configWriter.setCap(10000); configWriter.setCap(false); configWriter.setHeuristics(true); configWriter.write(); // Create configuration file } catch (IRPIOException e1) { out.log("Error. Unable to create default configuration file."); } catch (FileNotFoundException e1) { out.log("Failed to find file."); } } } catch (IRPVersionMismatch e) { out.log("Error. Version of configuration file is incompatible."); } new Thread() { @Override public void run() { updateScan(); } }.run(); }
From source file:com.git.ifly6.IRPController.java
@FXML void changeEndoCap(ActionEvent event) { if (endoCapEnabled.isSelected()) { String input = ""; TextInputDialog dialog = new TextInputDialog("Endorsement cap"); dialog.setTitle("IRP Settings"); dialog.setHeaderText("Change endorsement cap"); dialog.setContentText("Enter an integer here:"); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { input = result.get();/*from www. jav a2s . c o m*/ } try { int capSet = Integer.parseInt(input); endorsementCap = capSet; // Write this fact to file. } catch (NumberFormatException e) { out.log("ERROR. Please provide an integer to the endorsement cap."); } } else { Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle("IRP Settings"); alert.setHeaderText("Endorsement Cap"); alert.setContentText( "You cannot change the endorsement cap if the endorsement cap system is disabled."); alert.showAndWait(); } // Show an alert to change the endorsement cap. // Save that change to file. }
From source file:be.makercafe.apps.makerbench.Main.java
private ContextMenu createViewerContextMenu() { ContextMenu rootContextMenu = new ContextMenu(); // Add Folder.. MenuItem addFolder = new MenuItem("Add folder.."); addFolder.setOnAction(new EventHandler<ActionEvent>() { @Override// w ww . j a v a 2 s .c om public void handle(ActionEvent event) { TextInputDialog dialog = new TextInputDialog("myfolder"); dialog.setTitle("New folder"); dialog.setHeaderText("Create a new folder"); dialog.setContentText("Folder name:"); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { ResourceTreeItem<String> item = (ResourceTreeItem<String>) viewer.getSelectionModel() .getSelectedItem(); File file = new File( item.getPath().toFile().getAbsolutePath() + File.separatorChar + result.get()); if (!file.exists()) { if (!file.mkdir()) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Error Dialog"); alert.setHeaderText("Error occured while creating folder"); alert.setContentText("Folder path: " + file.getAbsolutePath()); alert.showAndWait(); } else { viewer.setRoot(setRootFolder(new File(pathMakerbenchHome))); } } } } }); // Delete folder MenuItem deleteFolder = new MenuItem("Delete folder.."); deleteFolder.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Confirmation Dialog"); alert.setHeaderText("Delete folder"); alert.setContentText("Please confirm deleteion of selected folder and all it's contents ?"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { ResourceTreeItem<String> item = (ResourceTreeItem<String>) viewer.getSelectionModel() .getSelectedItem(); File file = new File(item.getPath().toFile().getAbsolutePath()); if (file.exists()) { try { FileUtils.deleteDirectory(file); viewer.setRoot(setRootFolder(new File(pathMakerbenchHome))); } catch (Exception e) { alert = new Alert(AlertType.ERROR); alert.setTitle("Error Dialog"); alert.setHeaderText("Error occured while deleting folder"); alert.setContentText("Error messsage: " + e.getMessage()); alert.showAndWait(); } } } } }); // Add File.. MenuItem addFile = new MenuItem("Add file.."); addFile.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { TextInputDialog dialog = new TextInputDialog("myfile.txt"); dialog.setTitle("New file"); dialog.setHeaderText("Create a new file (.jfxscad, .jfxmill, .txt, .md, .xml, .gcode"); dialog.setContentText("File name:"); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { ResourceTreeItem<String> item = (ResourceTreeItem<String>) viewer.getSelectionModel() .getSelectedItem(); File file = new File( item.getPath().toFile().getAbsolutePath() + File.separatorChar + result.get()); if (!file.exists()) { try { file.createNewFile(); viewer.setRoot(setRootFolder(new File(pathMakerbenchHome))); } catch (Exception e) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("Error Dialog"); alert.setHeaderText("Error occured while creating file"); alert.setContentText( "File path: " + file.getAbsolutePath() + "\nError message: " + e.getMessage()); alert.showAndWait(); } } } } }); // Delete file MenuItem deleteFile = new MenuItem("Delete file.."); deleteFile.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Confirmation Dialog"); alert.setHeaderText("Delete file"); alert.setContentText("Please confirm deleteion of selected file"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { ResourceTreeItem<String> item = (ResourceTreeItem<String>) viewer.getSelectionModel() .getSelectedItem(); File file = new File(item.getPath().toFile().getAbsolutePath()); if (file.exists()) { if (!file.delete()) { alert = new Alert(AlertType.ERROR); alert.setTitle("Error Dialog"); alert.setHeaderText("Error occured while deleting file"); alert.setContentText("File path: " + file.getAbsolutePath()); alert.showAndWait(); } else { viewer.setRoot(setRootFolder(new File(pathMakerbenchHome))); } } } } }); rootContextMenu.getItems().addAll(addFolder, deleteFolder, addFile, deleteFile); return rootContextMenu; }
From source file:com.git.ifly6.IRPController.java
@FXML void changeRegion(ActionEvent event) { String newRegion = ""; TextInputDialog dialog = new TextInputDialog("Region name"); dialog.setTitle("IRP Settings"); dialog.setHeaderText("Change Region"); dialog.setContentText("Enter the region name here:"); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { newRegion = result.get();/*from w w w .j av a 2 s . c om*/ } boolean exists = false; try { exists = new NSRegion(newRegion).exists(); } catch (Exception e1) { out.log("ERROR. Cannot confirm region existence."); } if (!newRegion.equals("") && exists) { configurationFile .renameTo(new File(IflyRegionProtection.workingDir + File.separator + regionName + ".txt")); File[] fileList = new File(IflyRegionProtection.workingDir).listFiles(); boolean preexisting = false; for (File element : fileList) { if (element.getName().equals(newRegion + ".txt")) { preexisting = true; } } if (preexisting) { new File(newRegion + ".txt").renameTo(configurationFile); } else { // Create new configuration file and copy setting stored in memory. } } else { out.log("Error. Please provide a valid region name."); } regionName = newRegion; }
From source file:be.makercafe.apps.makerbench.Main.java
/** * Creates the menubar/* ww w . j a v a2s. com*/ * * @return */ private MenuBar createMenuBar() { MenuBar bar = new MenuBar(); Menu projectMenu = new Menu("Project"); MenuItem openProject = new MenuItem("Open..."); openProject.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { directoryChooser.setTitle("Please choose a project folder"); File file = directoryChooser.showDialog(stage); viewer.setRoot(setRootFolder(file)); } }); Menu newProject = new Menu("New"); MenuItem newFolder = new MenuItem("Folder..."); newFolder.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { TextInputDialog dialog = new TextInputDialog("my_project_folder"); dialog.setTitle("New folder"); dialog.setHeaderText("Create a new folder"); dialog.setContentText("Folder name:"); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { String homeDir = System.getProperty("user.home"); System.out.println("Folder name: " + result.get()); System.out.println("User home: " + homeDir); } } }); newProject.getItems().add(newFolder); MenuItem importProject = new MenuItem("Import"); importProject.setAccelerator(new KeyCodeCombination(KeyCode.I, KeyCombination.CONTROL_DOWN)); importProject.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { System.out.println("Import"); } }); MenuItem deleteProject = new MenuItem("Delete"); deleteProject.setAccelerator(new KeyCodeCombination(KeyCode.D, KeyCombination.CONTROL_DOWN)); deleteProject.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { System.out.println("Delete"); } }); projectMenu.getItems().addAll(openProject, newProject, importProject, deleteProject); Menu helpMenu = new Menu("Help"); MenuItem aboutItem = new MenuItem("About"); aboutItem.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle("Information Dialog"); alert.setHeaderText("About makerbench"); alert.setContentText( "Makerbench is an open source IDE for designing and manufacturing objects and code.\nWritten by Luc De pauw\n\nUses opensource libraries from the next projects:\n-RichtextFX by Tomas Mikula\n-JCSG by Michael Hoffer\n-ControlsFX by FXexperience.com"); alert.showAndWait(); } }); helpMenu.getItems().add(aboutItem); bar.getMenus().addAll(projectMenu, helpMenu); return bar; }
From source file:io.github.mzmine.modules.plots.msspectrum.MsSpectrumPlotWindowController.java
public void handleSetMzShiftManually(Event event) { DecimalFormat mzFormat = MZmineCore.getConfiguration().getMZFormat(); String newMzShiftString = "0.0"; Double newMzShift = (Double) setToMenuItem.getUserData(); if (newMzShift != null) newMzShiftString = mzFormat.format(newMzShift); TextInputDialog dialog = new TextInputDialog(newMzShiftString); dialog.setTitle("m/z shift"); dialog.setHeaderText("Set m/z shift value"); Optional<String> result = dialog.showAndWait(); result.ifPresent(value -> {//from w w w. j a v a2s. c o m try { double newValue = Double.parseDouble(value); mzShift.set(newValue); } catch (Exception e) { e.printStackTrace(); } }); }
From source file:editeurpanovisu.EditeurPanovisu.java
public static void creerEditerDiaporama(String strDiaporama) { apCreationDiaporama.getChildren().clear(); apCreationDiaporama.setStyle("-fx-background-color : -fx-base;" + "-fx-border-color: derive(-fx-base,10%);" + "-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.5) , 8, 0.0 , 0 , 8 );" + "-fx-border-width: 1px;"); mbarPrincipal.setDisable(true);/*from w w w . jav a2 s. co m*/ bbarPrincipal.setDisable(true); hbBarreBouton.setDisable(true); tpEnvironnement.setDisable(true); Rectangle2D tailleEcran = Screen.getPrimary().getBounds(); int iLargeurEcran = (int) tailleEcran.getWidth(); int iHauteurEcran = (int) tailleEcran.getHeight() - 100; final int iLargeur = 800; final int iHauteur = 630; Label lblNomDiapo = new Label(rbLocalisation.getString("main.nomDiapo")); lblNomDiapo.setLayoutX(30); lblNomDiapo.setLayoutY(45); ComboBox cbListeDiapo = new ComboBox(); cbListeDiapo.setLayoutX(150); cbListeDiapo.setLayoutY(40); cbListeDiapo.setValue(""); for (int i = 0; i < getiNombreDiapo(); i++) { cbListeDiapo.getItems().add(diaporamas[i].getStrNomDiaporama()); } Button btnNouveauDiapo = new Button(rbLocalisation.getString("diapo.nouveau")); btnNouveauDiapo.setLayoutX(iLargeur - 330); btnNouveauDiapo.setLayoutY(20); btnNouveauDiapo.setPrefSize(140, 60); Button btnEffaceDiapo = new Button(rbLocalisation.getString("diapo.efface")); btnEffaceDiapo.setLayoutX(iLargeur - 170); btnEffaceDiapo.setLayoutY(20); btnEffaceDiapo.setPrefSize(140, 60); gestDiapo = new GestionnaireDiaporamaController(); gestDiapo.initDiaporama(); apCreationDiaporama.getChildren().addAll(lblNomDiapo, cbListeDiapo, btnEffaceDiapo, btnNouveauDiapo, gestDiapo.apDiaporama); apCreationDiaporama.setPrefWidth(iLargeur); apCreationDiaporama.setMinWidth(iLargeur); apCreationDiaporama.setMaxWidth(iLargeur); apCreationDiaporama.setPrefHeight(iHauteur); apCreationDiaporama.setMinHeight(iHauteur); apCreationDiaporama.setMaxHeight(iHauteur); apCreationDiaporama.setLayoutX((iLargeurEcran - iLargeur) / 2); apCreationDiaporama.setLayoutY((iHauteurEcran - iHauteur) / 2); apCreationDiaporama.setVisible(true); gestDiapo.addPropertyChangeListener("valideDiapo", (e) -> { mbarPrincipal.setDisable(false); bbarPrincipal.setDisable(false); hbBarreBouton.setDisable(false); tpEnvironnement.setDisable(false); apCreationDiaporama.setVisible(false); gestDiapo.diapoSauve = true; boolean bTrouve = false; int iTrouve = -1; for (int i = 0; i < getiNombreDiapo(); i++) { if (diaporamas[i].getStrNomDiaporama().equals(cbListeDiapo.getValue())) { bTrouve = true; iTrouve = i; } } if (bTrouve) { diaporamas[iTrouve] = gestDiapo.getDiaporama(); try { creeDiaporamaHTML(diaporamas[iTrouve], iTrouve); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } gestDiapo.reInit(new Diaporama()); }); gestDiapo.addPropertyChangeListener("visualiseDiapo", (e) -> { try { creeDiaporamaHTML(gestDiapo.getDiaporama(), -1); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } String strNomFichier = getStrRepertTemp() + File.separator + "diaporama" + File.separator + "diapo-1.html"; webEngine.load("file:///" + strNomFichier); apWebview.getChildren().clear(); browser.setPrefSize(apWebview.getPrefWidth() - 20, apWebview.getPrefHeight() - 50); browser.setTranslateX(10); browser.setTranslateY(10); apWebview.getChildren().add(browser); Button btnOk = new Button("Ok"); btnOk.setPrefSize(100, 20); btnOk.setLayoutX(apWebview.getPrefWidth() - 110); btnOk.setLayoutY(apWebview.getPrefHeight() - 30); apWebview.getChildren().add(btnOk); apWebview.setVisible(true); btnOk.setOnMouseClicked((me) -> { apWebview.setVisible(false); apWebview.getChildren().clear(); }); }); gestDiapo.addPropertyChangeListener("annuleDiapo", (e) -> { mbarPrincipal.setDisable(false); bbarPrincipal.setDisable(false); hbBarreBouton.setDisable(false); tpEnvironnement.setDisable(false); apCreationDiaporama.setVisible(false); gestDiapo.diapoSauve = true; gestDiapo.reInit(new Diaporama()); }); cbListeDiapo.valueProperty().addListener((ov, old_val, new_val) -> { if (new_val != null) { ButtonType reponse = null; ButtonType buttonTypeOui = new ButtonType(rbLocalisation.getString("main.oui")); ButtonType buttonTypeNon = new ButtonType(rbLocalisation.getString("main.non")); if (!gestDiapo.diapoSauve) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle(rbLocalisation.getString("diapo.sauver")); alert.setHeaderText(null); alert.setContentText(rbLocalisation.getString("diapo.sauverTexte")); alert.getButtonTypes().clear(); alert.getButtonTypes().setAll(buttonTypeOui, buttonTypeNon); Optional<ButtonType> actReponse = alert.showAndWait(); reponse = actReponse.get(); } if (reponse == buttonTypeOui) { boolean bTrouve = false; int iTrouve = -1; for (int i = 0; i < getiNombreDiapo(); i++) { if (diaporamas[i].getStrNomDiaporama().equals(old_val)) { bTrouve = true; iTrouve = i; } } if (bTrouve) { diaporamas[iTrouve] = gestDiapo.getDiaporama(); try { creeDiaporamaHTML(diaporamas[iTrouve], iTrouve); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } } gestDiapo.diapoSauve = true; boolean bTrouve = false; int iTrouve = -1; for (int i = 0; i < getiNombreDiapo(); i++) { if (diaporamas[i].getStrNomDiaporama().equals(new_val)) { bTrouve = true; iTrouve = i; } } if (bTrouve) { gestDiapo.setbDisabled(false); gestDiapo.reInit(diaporamas[iTrouve]); } } }); btnNouveauDiapo.setOnMouseClicked((me) -> { ButtonType reponse = null; ButtonType buttonTypeOui = new ButtonType(rbLocalisation.getString("main.oui")); ButtonType buttonTypeNon = new ButtonType(rbLocalisation.getString("main.non")); if (!gestDiapo.diapoSauve) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle(rbLocalisation.getString("diapo.sauver")); alert.setHeaderText(null); alert.setContentText(rbLocalisation.getString("diapo.sauverTexte")); alert.getButtonTypes().clear(); alert.getButtonTypes().setAll(buttonTypeOui, buttonTypeNon); Optional<ButtonType> actReponse = alert.showAndWait(); reponse = actReponse.get(); } if (reponse == buttonTypeOui) { gestDiapo.diapoSauve = true; boolean bTrouve = false; int iTrouve = -1; for (int i = 0; i < getiNombreDiapo(); i++) { if (diaporamas[i].getStrNomDiaporama().equals(cbListeDiapo.getValue())) { bTrouve = true; iTrouve = i; } } if (bTrouve) { diaporamas[iTrouve] = gestDiapo.getDiaporama(); try { creeDiaporamaHTML(diaporamas[iTrouve], iTrouve); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } } TextInputDialog dialog = new TextInputDialog(""); dialog.setTitle(rbLocalisation.getString("main.nomDiapo")); dialog.setHeaderText(null); dialog.setContentText(rbLocalisation.getString("diapo.entrerNom")); Optional<String> resultat = dialog.showAndWait(); if (resultat.isPresent()) { String nomDiapo = resultat.get(); boolean bTrouve = false; for (int i = 0; i < getiNombreDiapo(); i++) { if (diaporamas[i].getStrNomDiaporama().equals(nomDiapo)) { bTrouve = true; } } if (!bTrouve) { diaporamas[getiNombreDiapo()] = new Diaporama(); diaporamas[getiNombreDiapo()].setStrNomDiaporama(nomDiapo); cbListeDiapo.getItems().add(nomDiapo); cbListeDiapo.setValue(nomDiapo); gestDiapo.setbDisabled(false); gestDiapo.reInit(diaporamas[getiNombreDiapo()]); setiNombreDiapo(getiNombreDiapo() + 1); } else { Alert alert = new Alert(AlertType.ERROR); alert.setTitle(rbLocalisation.getString("diapo.erreur")); alert.setHeaderText(null); alert.setContentText(rbLocalisation.getString("diapo.erreurNom")); alert.showAndWait(); } } }); }
From source file:utilitybasedfx.MainGUIController.java
@FXML public void eventFileNew(ActionEvent event) { SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd_HHmmss"); TextInputDialog dialog = new TextInputDialog("Project_" + sdf.format((Calendar.getInstance().getTime()))); dialog.setTitle("Please specify a project name"); dialog.setHeaderText("This will be the name of your project and cannot easily be changed.\n" + "The name should be a legal filename."); dialog.setContentText("New project name:"); boolean shouldContinue = true; boolean resultValid = false; String res = ""; do {/*from ww w .j a va2s. c o m*/ Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { res = result.get(); if (Utils.validFileName(res)) { if (Utils.dirExist(Prefs.getSavePath() + "/" + res)) { dialog.setHeaderText("This will be the name of your project and cannot easily be changed.\n" + "The name should be a legal filename.\n\n" + "This project already exists"); } else { resultValid = true; shouldContinue = false; } } else { dialog.setHeaderText("This will be the name of your project and cannot easily be changed.\n" + "The name should be a legal filename.\n\n" + "The name you specified is not legal, try again"); } } else { shouldContinue = false; } } while (shouldContinue); if (resultValid) { createProject(res); setActiveProject(res); } }