List of usage examples for javafx.stage FileChooser FileChooser
FileChooser
From source file:be.makercafe.apps.makerbench.editors.GCodeEditor.java
private void handleExportAsPngFile(ActionEvent e) { if (csgObject == 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();// www . jav a2 s .co m 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:com.github.drbookings.ui.controller.MainController.java
@FXML private void handleMenuItemOpenBookingExcel(final ActionEvent event) { if (logger.isDebugEnabled()) { logger.debug("Opening BookingBean Excel"); }/*from w w w . ja v a2 s . c o m*/ final FileChooser fileChooser = new FileChooser(); fileChooser.getExtensionFilters().addAll( new FileChooser.ExtensionFilter("Excel", Arrays.asList("*.xls", "*.XLS")), new FileChooser.ExtensionFilter("All Files", "*")); fileChooser.setTitle("Open BookingBean Excel"); final File file = fileChooser.showOpenDialog(node.getScene().getWindow()); if (file != null) { final BookingReaderService reader = new BookingReaderService(getManager(), new XlsxBookingFactory(file)); reader.start(); } }
From source file:org.sandsoft.acefx.AceEditor.java
@FXML private void openButtonOnAction() { try {/*from w w w . j a v a 2s .c o m*/ FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Open file"); attachFilters(fileChooser); if (mFilePath != null) { fileChooser.setInitialFileName(mFilePath.getName()); fileChooser.setInitialDirectory(mFilePath.getParentFile()); } File file = fileChooser.showOpenDialog(this.getScene().getWindow()); if (file != null) { openFile(file); } } catch (Exception ex) { Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex); } }
From source file:org.sandsoft.acefx.AceEditor.java
@FXML private void saveButtonOnAction() { try {// w w w.ja v a2 s . c om if (mFilePath != null) { saveFile(); return; } FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Save file"); attachFilters(fileChooser); File file = fileChooser.showSaveDialog(this.getScene().getWindow()); if (file != null) { saveAs(file); } } catch (IOException | NullPointerException ex) { Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex); } }
From source file:de.perdoctus.ebikeconnect.gui.ActivitiesOverviewController.java
private void exportCurrentActivity(final ExportService exportService) { final FileChooser fileChooser = new FileChooser(); fileChooser.setTitle(exportService.getFileTypeDescription()); fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter( exportService.getFileTypeDescription(), "*." + exportService.getFileExtension())); final File file = fileChooser.showSaveDialog(chart.getScene().getWindow()); if (file != null) { exportService.setActivityDetails(this.currentActivityDetailsGroup.get().getActivitySegments()); exportService.setFile(file);/*from ww w.j a v a 2s . c o m*/ exportService.restart(); } }
From source file:uk.bl.dpt.qa.gui.DissimilarGUIThread.java
@FXML void openFile(ActionEvent event) { FileChooser chooser = new FileChooser(); chooser.setTitle("Choose an input CSV file..."); chooser.getExtensionFilters().add(new ExtensionFilter("CSV file with input pairs", "*.csv")); chooser.setInitialDirectory(new File("f:/eclipse-workspace/dissimilar/")); Window window = mainPane.getScene().getWindow(); File inputFile = chooser.showOpenDialog(window); if (inputFile != null && inputFile.exists()) { internalOpenFile(inputFile);/* ww w . java 2 s. c om*/ } }
From source file:genrsa.GenRSAController.java
/** * Mtodo usado cuando se pulsa el boton de generarLog de NNC * @param event //from w ww . j a v a 2 s .co m */ public void generateNNC(ActionEvent event) { if (this.startLogNNC) { //todo se hace antes del thread porque si no nose podria manejar la ventana //para que se decidiera donde se guarda el archivo. FileChooser.ExtensionFilter extensionFilter = new FileChooser.ExtensionFilter("HTML files", "*.html"); FileChooser fileChooser = new FileChooser(); fileChooser.setInitialDirectory(new File(System.getProperty("user.dir"))); fileChooser.getExtensionFilters().add(extensionFilter); fileChooser.setTitle("Seleccionar directorio donde guardar el log"); fileChooser.setInitialFileName("LogNNC genRSA"); File logNNCFile = fileChooser.showSaveDialog(labelPubKey.getScene().getWindow()); Task CAstart = new Task() { @Override protected Object call() throws Exception { startLogNNC = false; progressNNC.setVisible(true); Platform.runLater(() -> { disableOnProgress(true); configureLogStop(true); }); manageKey.saveLogNNC(progressNNC, RSA, logNNCFile); Platform.runLater(() -> { disableOnProgress(false); configureLogStop(false); }); progressNNC.setVisible(false); startLogNNC = true; return null; } }; new Thread(CAstart).start(); } else { this.manageKey.setLogCancelled(); this.startLogNNC = true; } }
From source file:com.danilafe.sbaccountmanager.StarboundServerAccountManager.java
private void parseJSON() { //Show the File Chooser FileChooser fc = new FileChooser(); fc.setTitle("Select Starbound AccessControl.config File"); File starbound = fc.showOpenDialog(null); config = starbound;// www.j a va 2 s . c o m if (starbound != null) { try { FileInputStream fis = new FileInputStream(starbound); JSONTokener jst = new JSONTokener(fis); JSONObject jsob = new JSONObject(jst); JSONObject accounts = jsob.getJSONObject("accounts"); JSONArray banned_accounts = jsob.getJSONArray("bannedAccountNames"); JSONArray banned_addresses = jsob.getJSONArray("bannedAddresses"); JSONArray banned_players = jsob.getJSONArray("bannedPlayerNames"); Iterator account_keys = accounts.keys(); while (account_keys.hasNext()) { String key = (String) account_keys.next(); users.remove(key); users.add(key); userpasswords.put(key, accounts.getJSONObject(key).getString("password")); } for (int i = 0; i < banned_accounts.length(); i++) { banned_usernames.add(banned_accounts.getString(i)); } for (int i = 0; i < banned_addresses.length(); i++) { banned_ips.add(banned_addresses.getString(i)); } for (int i = 0; i < banned_players.length(); i++) { banned_playernames.add(banned_players.getString(i)); } } catch (FileNotFoundException ex) { //In theory this shouldn't happen. System.exit(1); } catch (JSONException ex) { ex.printStackTrace(); System.exit(1); } } }
From source file:com.core.meka.SOMController.java
private String cargarArrayDesdeArchivo() throws IOException { String result = ""; FileChooser chooser = new FileChooser(); chooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Text doc(*.txt)", "*.txt")); File file = chooser.showOpenDialog(base.getScene().getWindow()); if (file != null) { if (file.getName().endsWith(".txt")) { String path = file.getAbsolutePath(); String array = Util.leerFichero(path); if (array != null && !array.isEmpty()) { String[] values = array.replaceAll("\\s+", "").replaceAll("\\n+", "").split(";"); for (String v : values) { result += v + ";\n"; }//from www.j av a 2 s .c o m } } else { Util.error("Extensin incorrecta", "Verifique la extension", file.getName() + " no tiene la extension correcta", act1); } } return result; }
From source file:uk.bl.dpt.qa.gui.DissimilarGUIThread.java
@FXML void saveResults(ActionEvent event) { FileChooser chooser = new FileChooser(); chooser.setTitle("Choose an output CSV file..."); chooser.getExtensionFilters().add(new ExtensionFilter("CSV file", "*.csv")); Window window = mainPane.getScene().getWindow(); File outputFile = chooser.showOpenDialog(window); if (outputFile != null) { //internalSaveFile(outputFile);//overwrite? gLogger.trace("FIXME: file saving"); } else {/*from ww w . j a v a2s . com*/ internalSaveFile(outputFile); } }