List of usage examples for javafx.scene.control Alert Alert
public Alert(@NamedArg("alertType") AlertType alertType)
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 {/* w w w.j a v a 2s. 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:cz.lbenda.rcp.DialogHelper.java
/** Ask user if file can be overwrite if file exist * @param file file which is rewrite/*from w w w . j a va2 s . com*/ * @param defaultExtension if file haven't extension then default is add * @return file if user want rewrite it, or no file with this name exist */ public File canBeOverwriteDialog(File file, String defaultExtension) { if (file == null) { return null; } if ("".equals(FilenameUtils.getExtension(file.getName()))) { file = new File(file.getAbsoluteFile() + "." + defaultExtension); } if (!file.exists()) { return file; } Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle(msgCanOverwriteTitle); alert.setContentText(String.format(msgCanOverwriteContent, file.getName())); Optional<ButtonType> result = alert.showAndWait(); return (result.isPresent()) && (result.get() == ButtonType.OK) ? file : null; }
From source file:editeurpanovisu.EquiCubeDialogController.java
/** * *///from w ww . ja va2 s .c o m private void annulerE2C() { ButtonType reponse = null; ButtonType buttonTypeOui = new ButtonType(rbLocalisation.getString("main.oui")); ButtonType buttonTypeNon = new ButtonType(rbLocalisation.getString("main.non")); if ((lvListeFichier.getItems().size() != 0) && (!bTraitementEffectue)) { Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle(rbLocalisation.getString("transformation.traiteImages")); alert.setHeaderText(null); alert.setContentText(rbLocalisation.getString("transformation.traiteImagesQuitte")); alert.getButtonTypes().setAll(buttonTypeOui, buttonTypeNon); Optional<ButtonType> actReponse = alert.showAndWait(); reponse = actReponse.get(); } if ((reponse == buttonTypeOui) || (reponse == null)) { bTraitementEffectue = false; stTransformations.hide(); } }
From source file:account.management.controller.inventory.AllProductWiseReportController.java
@FXML private void onShowReportClick(ActionEvent event) { this.show.setDisable(true); try {// w ww . j a va 2 s . c o m String start_date = "1980-01-01", end_date = "2050-12-31"; start_date = new SimpleDateFormat("yyyy-MM-dd") .format(new SimpleDateFormat("yyyy-MM-dd").parse(this.start.getValue().toString())); end_date = new SimpleDateFormat("yyyy-MM-dd") .format(new SimpleDateFormat("yyyy-MM-dd").parse(this.end.getValue().toString())); HttpResponse<JsonNode> res = Unirest.get(MetaData.baseUrl + "report/product/all/sellPurchase") .queryString("start", start_date).queryString("end", end_date).asJson(); JSONArray array = res.getBody().getArray(); Vector v = new Vector(); HashMap params = new HashMap(); params.put("date", "From " + new SimpleDateFormat("dd-MM-yyyy") .format(new SimpleDateFormat("yyyy-MM-dd").parse(start_date)) + " To " + new SimpleDateFormat("dd-MM-yyyy") .format(new SimpleDateFormat("yyyy-MM-dd").parse(end_date))); for (int i = 0; i < array.length(); i++) { JSONObject obj = array.getJSONObject(i); String id = obj.get("id").toString().equals("null") ? "-" : obj.get("id").toString(); String name = obj.get("name").toString().equals("null") ? "-" : obj.get("name").toString(); String ob = obj.get("ob").toString().equals("null") ? "-" : obj.get("ob").toString(); String p_qty = obj.get("p_qty").toString().equals("null") ? "-" : obj.get("p_qty").toString(); String p_rate = obj.get("p_rate").toString().equals("null") ? "-" : obj.get("p_rate").toString(); String p_total = obj.get("p_total").toString().equals("null") ? "-" : obj.get("p_total").toString(); String s_qty = obj.get("s_qty").toString().equals("null") ? "-" : obj.get("s_qty").toString(); String s_rate = obj.get("s_rate").toString().equals("null") ? "-" : obj.get("s_rate").toString(); String s_total = obj.get("s_total").toString().equals("null") ? "-" : obj.get("s_total").toString(); v.add(new AllProductWiseReport(id, name, ob, p_qty, p_rate, p_total, s_qty, s_rate, s_total)); } Report report = new Report(); report.getReport("src\\report\\AllProductPurchaseSellReport.jrxml", new JRBeanCollectionDataSource(v), params, "Products Report"); } catch (ParseException ex) { Logger.getLogger(AllProductWiseReportController.class.getName()).log(Level.SEVERE, null, ex); Alert alert = new Alert(Alert.AlertType.ERROR); alert.setHeaderText(null); alert.setContentText("Please Enter date correctly."); alert.setGraphic(new ImageView(new Image("resources/error.jpg"))); alert.showAndWait(); } catch (UnirestException ex) { Logger.getLogger(AllProductWiseReportController.class.getName()).log(Level.SEVERE, null, ex); Alert alert = new Alert(Alert.AlertType.ERROR); alert.setHeaderText(null); alert.setContentText("Sorry!! there is an error in the server. Please try again."); alert.setGraphic(new ImageView(new Image("resources/error.jpg"))); alert.showAndWait(); } finally { this.show.setDisable(false); } }
From source file:de.micromata.mgc.javafx.launcher.gui.AbstractMainWindow.java
@Override public void initializeWithModel() { Thread currentThread = Thread.currentThread(); currentThread.setUncaughtExceptionHandler(model.getUncaughtExceptionHandler()); addCss();//from ww w . ja va 2 s . c om LauncherLocalSettingsConfigModel config = MgcLauncher.getLauncherConfig(); if (config.isEnableLF5() == false) { launchMenu.setVisible(false); } if (SystemService.get().getOsType() != OsType.Windows) { hideWindowMenu.setVisible(false); } stage.setOnCloseRequest(event -> { if (SystemService.get().getOsType() != OsType.Windows) { event.consume(); Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle(model.getTranslateService().translate("mgc.launcher.gui.quitconfirmation.title")); alert.setHeaderText( model.getTranslateService().translate("mgc.launcher.gui.quitconfirmation.header")); alert.setContentText( model.getTranslateService().translate("mgc.launcher.gui.quitconfirmation.message")); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { closeApplication(null); } } }); startServerButton.setOnAction(e -> { startServer(); }); stopServerButton.setOnAction(e -> { stopServer(); }); stopServerButton.setDisable(true); boolean runnin = MgcLauncher.get().getApplication().isRunning(); startServerButton.setDisable(runnin); stopServerButton.setDisable(runnin == false); openBrowser.setDisable(runnin == false); addStartServerEventHandler(); addStopServerEventHandler(); openBrowser.setOnAction(e -> { launchBrowser(); }); loggingPane.widthProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneWidth, Number newSceneWidth) { loggingController.adjustWidth(newSceneWidth.doubleValue()); } }); loggingPane.heightProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneWidth, Number newSceneWidth) { loggingController.adjustHeight(newSceneWidth.doubleValue()); } }); loggingController.adjustHeight(loggingPane.getHeight()); loggingController.adjustWidth(loggingPane.getWidth()); MgcEventRegistries.getEventInstanceRegistry() .registerListener(new MgcApplicationStartStopToEventListener()); String helpUrl = getModel().getApplicationInfo().getHelpUrl(); if (StringUtils.isBlank(helpUrl) == true) { helpButton.setVisible(false); } else { helpButton.setOnAction(event -> { SystemService.get().openUrlInBrowser(helpUrl); }); } FXEvents.get().addEventHandler(this, stopServerButton, MgcLauncherEvent.APP_STARTED, event -> { if (config.isStartBrowserOnStartup() == true) { launchBrowser(); } }); }
From source file:ubicrypt.ui.ctrl.MainController.java
public void about(ActionEvent actionEvent) { Alert about = new Alert(Alert.AlertType.INFORMATION); about.setTitle("UbiCrypt"); about.setHeaderText("Version: " + UbiCrypt.getVersion()); about.setContentText("Author: Giancarlo Frison <giancarlo@gfrison.com>"); about.initOwner(stage);/*from w w w .ja v a2s . co m*/ about.showAndWait(); }
From source file:cz.lbenda.rcp.DialogHelper.java
/** Inform user about not existing file */ public void fileNotExist(File file) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle(msgFileNotExistTitle); alert.setHeaderText(String.format(msgFileNotExistHeader, file.getName())); alert.setContentText(msgFileNotExistContent); alert.show();/*w ww. j a v a 2 s . c o m*/ }
From source file:org.apache.cayenne.modeler.layout.MainWindowLayout.java
public MainWindowLayout() throws IOException { super(new Stage(), "/layouts/MainWindowLayout.fxml"); setMinimumWindowSize(900, 700);/*from w ww . ja va2s . c om*/ getStage().setOnCloseRequest(event -> { LOGGER.debug("Window is closing!"); // ideas for checking if window should save before closing or cancel, etc: // event.consume(); <- Prevents window from closing // http://stackoverflow.com/questions/31540500/alert-box-for-when-user-attempts-to-close-application-using-setoncloserequest-in // http://stackoverflow.com/questions/23160573/javafx-stage-setoncloserequest-without-function if (cayenneProject.isDirty()) { final Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Close Window"); alert.setHeaderText("Unsaved Changes"); alert.setContentText("Are you sure you want to close this window and lose your changes?"); final Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { // ... user chose OK } else { // ... user chose CANCEL or closed the dialog event.consume(); } } }); }
From source file:com.playonlinux.javafx.mainwindow.library.ViewLibrary.java
public void setUpEvents() { libraryItems.setOnChange(this::update); runScript.setOnMouseClicked(event -> { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Open a script"); File scriptToRun = fileChooser.showOpenDialog(parent); try {//from w w w . ja v a 2 s .com if (scriptToRun != null) { eventHandlerLibrary.runLocalScript(scriptToRun); } } catch (PlayOnLinuxException e) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle(translate("Error while trying to run the script.")); alert.setContentText("The file was not found"); LOGGER.warn("Error while trying to run the script", e); } }); runConsole.setOnMouseClicked(event -> runConsole()); }
From source file:ExcelFx.FXMLDocumentController.java
@FXML private void Open(ActionEvent event) throws NullPointerException, IOException { System.out.println("-----------------------------------------------------------"); System.out.println("Pressed open Button "); File universityFile = new File("university.json"); File collegeFile = new File("college.json"); System.out.println("University File emty is " + String.valueOf(universityFile.length() == 0)); System.out.println("College File emty is " + String.valueOf(collegeFile.length() == 0)); //File codesFile = new File("codes.json"); if ((universityFile.exists()) && (collegeFile.exists()) /*&& (codesFile.exists())*/) { try {//from ww w .j a v a 2s .c o m this.universityJson.jsonRead("university.json"); this.collegeJson.jsonRead("college.json"); //this.codesJson.jsonRead("codes.json"); this.jsonXLSXData.setAll(universityJson, collegeJson/*, codesJson*/); } catch (IOException | ParseException ex) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle(""); alert.setHeaderText(" ? ? "); alert.setContentText(ex.toString()); alert.showAndWait(); Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE, null, ex); } } else { try { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("FileOpenFXML.fxml")); this.fileOpenParent = (Parent) fxmlLoader.load(); Stage stage = new Stage(); stage.initModality(Modality.APPLICATION_MODAL); stage.initStyle(StageStyle.DECORATED); stage.setTitle(" "); stage.setScene(new Scene(this.fileOpenParent)); stage.showAndWait(); } catch (Exception e) { System.err.println(e); } this.jsonXLSXData.setAll(universityJson, collegeJson/*, codesJson*/); } FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("InitalData.fxml")); Parent root1 = (Parent) fxmlLoader.load(); Stage stage = new Stage(); stage.initModality(Modality.APPLICATION_MODAL); stage.initStyle(StageStyle.DECORATED); stage.setTitle(" "); stage.setScene(new Scene(root1)); stage.showAndWait(); setProgressBar(-1.); Task task = new Task<Void>() { @Override protected Void call() throws Exception { initaldata = (JsonWrite) root1.getUserData(); System.out.println("Inital Data empty is " + initaldata.isEmpty()); initaldata.setPage(String.valueOf(Integer.parseInt(initaldata.getPage()) - 1)); Parser parser = new Parser(); list = parser.parseInitalData(initaldata.getPatch(), Integer.parseInt(initaldata.getPage())); //System.out.println(list.size()); Sort sort = new Sort(list, jsonXLSXData, initaldata.getYStart(), initaldata.getYEnd()); HashMap<String, HashMap<String, ArrayList<String>>> hm = sort .professionsGrouping(initaldata.getYStart(), initaldata.getYEnd()); sortProf = sort.addWay(hm); return null; } }; mainProcessing(task); System.out.println("button open finished"); System.out.println("-----------------------------------------------------------"); }