List of usage examples for javafx.stage FileChooser showOpenDialog
public File showOpenDialog(final Window ownerWindow)
From source file:net.sourceforge.entrainer.gui.EntrainerFX.java
private void loadLabSettings() { FileChooser chooser = getLabFileChooser("Load"); File labfile = chooser.showOpenDialog(null); if (labfile != null) loadLab(labfile);//w w w .ja v a2 s . co m }
From source file:view.FXApplicationController.java
@FXML protected void importHypnogrammAction() { FileChooser fileChooser = new FileChooser(); // Set extension filter FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("TXT files (*.txt)", "*.txt"); fileChooser.getExtensionFilters().add(extFilter); // Show open file dialog final File file = fileChooser.showOpenDialog(primaryStage); if (file != null) { try {// w w w.j a va 2 s .com openFile(file); hypnogram.updateAll(); updateWindows(); System.out.println("Finished importing Hypnogramm!"); } catch (IOException e) { popUp.createPopup("Error during importing Hypnogramm!"); Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Error during importing Hypnogramm!", e); } } }
From source file:ui.main.MainViewController.java
private void sendFile() { if (!contactsManager.getAvailabilityforSharing(currentChat.getParticipant())) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("Attention!"); alert.setHeaderText("The user is not available!"); alert.setContentText("The file receiving user should be available online to receive the file."); alert.showAndWait();//from w ww .j av a 2 s . co m return; } ItemType type = contactsManager.getUserType(currentChat.getParticipant()); if (type.equals(ItemType.none)) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("Attention!"); alert.setHeaderText("This user is not available for you!"); alert.setContentText( "The user has not accepted the Friend Request." + " The user is not available for you."); alert.showAndWait(); return; } else if (type.equals(ItemType.from)) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("Attention!"); alert.setHeaderText("An unaccepted user!"); alert.setContentText("You have not accepted the Friend Request." + " You can not send any messages until you accept the friend request."); alert.showAndWait(); return; } else if (type.equals(ItemType.to)) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("Attention!"); alert.setHeaderText("The user has not accepted!"); alert.setContentText("The user has not accepted the Friend Request." + " You can not send any messages until the user accepts the friend request."); alert.showAndWait(); return; } if (!contactsManager.getAvailabilityforSharing(currentChat.getParticipant())) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("Attention!"); alert.setHeaderText("The user is not available!"); alert.setContentText("The file receiving user should be available online to receive the file."); alert.showAndWait(); return; } FileChooser fc = new FileChooser(); File file = fc.showOpenDialog(presence.getScene().getWindow()); if (file == null) { return; } Thread t = new Thread(new Runnable() { @Override public void run() { try { fileManager.sendFile(file, currentChat.getParticipant()); if (history.isSelected()) { Timestamp time = new Timestamp(System.currentTimeMillis()); DBSingleChat.saveFileMessage(currentChat.getParticipant(), false, file.getPath(), time); } paintSentFile(currentChat, file.getAbsolutePath(), dtfT.print(DateTime.now())); Task tt = new Task() { @Override protected Object call() throws Exception { Thread.sleep(500); return new Object(); } }; tt.setOnSucceeded(value -> scrollPane.setVvalue(scrollPane.getHmax())); Thread thread1 = new Thread(tt); thread1.start(); } catch (FileNotFoundException ex) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("IMP"); alert.setHeaderText("File is not Found!"); alert.setContentText("File you selected does not exist."); alert.showAndWait(); return; } } }); t.start(); }
From source file:com.bekwam.resignator.ResignatorAppMainViewController.java
@FXML public void browseSource() { if (logger.isDebugEnabled()) { logger.debug("[BROWSE SOURCE]"); }// ww w . j av a 2s .co m clearValidationErrors(); switch (activeProfile.getArgsType()) { case JAR: FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Select Source JAR"); fileChooser.setInitialDirectory(new File(jarDir)); fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("JAR", "*.jar")); File f = fileChooser.showOpenDialog(stage); if (f != null) { if (logger.isDebugEnabled()) { logger.debug("[BROWSE SOURCE] selected file={}", f.getAbsolutePath()); } tfSourceFile.setText(f.getAbsolutePath()); jarDir = FilenameUtils.getFullPath(f.getAbsolutePath()); } break; case FOLDER: DirectoryChooser dirChooser = new DirectoryChooser(); dirChooser.setTitle("Select Source Folder"); dirChooser.setInitialDirectory(new File(jarDir)); File d = dirChooser.showDialog(stage); if (d != null) { if (logger.isDebugEnabled()) { logger.debug("[BROWSE SOURCE] selected dir={}", d.getAbsolutePath()); } tfSourceFile.setText(d.getAbsolutePath()); jarDir = FilenameUtils.getFullPath(d.getAbsolutePath()); } break; } }
From source file:com.bekwam.resignator.ResignatorAppMainViewController.java
@FXML public void browseTarget() { if (logger.isDebugEnabled()) { logger.debug("[BROWSE TARGET]"); }//from ww w. j av a 2 s . co m clearValidationErrors(); switch (activeProfile.getArgsType()) { case JAR: FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Select Target JAR"); fileChooser.setInitialDirectory(new File(jarDir)); fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("JAR", "*.jar")); File f = fileChooser.showOpenDialog(stage); if (f != null) { if (logger.isDebugEnabled()) { logger.debug("[BROWSE TARGET] selected file={}", f.getAbsolutePath()); } tfTargetFile.setText(f.getAbsolutePath()); jarDir = FilenameUtils.getFullPath(f.getAbsolutePath()); } break; case FOLDER: DirectoryChooser dirChooser = new DirectoryChooser(); dirChooser.setTitle("Select Target Folder"); dirChooser.setInitialDirectory(new File(jarDir)); File d = dirChooser.showDialog(stage); if (d != null) { if (logger.isDebugEnabled()) { logger.debug("[BROWSE TARGET] selected dir={}", d.getAbsolutePath()); } tfTargetFile.setText(d.getAbsolutePath()); jarDir = FilenameUtils.getFullPath(d.getAbsolutePath()); } break; } }
From source file:ui.main.MainViewController.java
private void sendImage() { if (!contactsManager.getAvailabilityforSharing(currentChat.getParticipant())) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("Attention!"); alert.setHeaderText("The user is not available!"); alert.setContentText("The file receiving user should be available online to receive the file."); alert.showAndWait();/*from w ww . j a v a 2 s . c o m*/ return; } ItemType type = contactsManager.getUserType(currentChat.getParticipant()); if (type.equals(ItemType.none)) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("Attention!"); alert.setHeaderText("The is not available for you!"); alert.setContentText( "The user has not accepted the Friend Request." + " The user is not available for you."); alert.showAndWait(); return; } else if (type.equals(ItemType.from)) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("Attention!"); alert.setHeaderText("The user has not accepted!"); alert.setContentText("The user has not accepted the Friend Request." + " You can not send any messages until the user accepts the friend request."); alert.showAndWait(); return; } else if (type.equals(ItemType.to)) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("Attention!"); alert.setHeaderText("The user has not accepted!"); alert.setContentText("The user has not accepted the Friend Request." + " You can not send any messages until the user accepts the friend request."); alert.showAndWait(); return; } try { FileChooser fc = new FileChooser(); fc.setTitle("Choose an image to send"); fc.getExtensionFilters().addAll( new FileChooser.ExtensionFilter("All Images", "*.jpg*", "*.png", "*.bmp"), new FileChooser.ExtensionFilter("JPG", "*.jpg"), new FileChooser.ExtensionFilter("PNG", "*.png"), new FileChooser.ExtensionFilter("BMP", "*.bmp")); File file = fc.showOpenDialog(presence.getScene().getWindow()); if (file == null) { return; } BufferedImage image = ImageIO.read(file); Thread t = new Thread(new Runnable() { @Override public void run() { try { fileManager.sendFile(file, currentChat.getParticipant()); if (history.isSelected()) { Timestamp time = new Timestamp(System.currentTimeMillis()); DBSingleChat.savePictureMessage(currentChat.getParticipant(), false, file.getPath(), time); } paintSentPhoto(currentChat, file, dtfT.print(DateTime.now())); Task tt = new Task() { @Override protected Object call() throws Exception { Thread.sleep(500); return new Object(); } }; tt.setOnSucceeded(value -> scrollPane.setVvalue(scrollPane.getHmax())); Thread thread1 = new Thread(tt); thread1.start(); } catch (FileNotFoundException ex) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("IMP"); alert.setHeaderText("File is not Found!"); alert.setContentText("File you selected does not exist."); alert.showAndWait(); return; } } }); t.start(); } catch (IOException ex) { Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:de.bayern.gdi.gui.Controller.java
/** * Opens up a file dialog to choose a config file to load. * * @return The chosen file//w ww . ja v a 2 s. c o m */ protected File openConfigFileOpenDialog() { FileChooser fileChooser = new FileChooser(); File initialDir = new File( Config.getInstance().getServices().getBaseDirectory().isEmpty() ? System.getProperty(USER_DIR) : Config.getInstance().getServices().getBaseDirectory()); fileChooser.setInitialDirectory(initialDir); fileChooser.setTitle(I18n.getMsg("menu.load_config")); fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("XML Files", "*.xml"), new FileChooser.ExtensionFilter("All Files", "*.*")); return fileChooser.showOpenDialog(primaryStage); }
From source file:snpviewer.SnpViewer.java
public void loadColourScheme(ActionEvent e) { FileChooser fileChooser = new FileChooser(); fileChooser.getExtensionFilters()/*from ww w .ja va 2 s . c o m*/ .add(new FileChooser.ExtensionFilter("SNP Viewer Colour Scheme", "*.svcols")); fileChooser.setTitle("Open SNP Viewer Colour Scheme (.svcols) file"); File loadFile = fileChooser.showOpenDialog(mainWindow); if (loadFile != null) { try { ObjectInputStream is = new ObjectInputStream( new BufferedInputStream(new FileInputStream(loadFile))); ArrayList<Color> loadedColors = new ArrayList<>(); for (Color c : colorComp) { String colorString = (String) is.readObject(); loadedColors.add(Color.valueOf(colorString)); } for (int ci = 0; ci < loadedColors.size(); ci++) { colorComponantSelector.getSelectionModel().clearAndSelect(ci); colorPicker.setValue(loadedColors.get(ci)); colorPicker.fireEvent(new ActionEvent()); } colorComponantSelector.getSelectionModel().selectFirst(); colorComp.clear(); colorComp.addAll(loadedColors); is.close(); saveProject(); removeSavedChromosomeImages(); refreshView((String) chromosomeSelector.getSelectionModel().getSelectedItem(), true); } catch (IOException | ClassNotFoundException ex) { } } }
From source file:snpviewer.SnpViewer.java
public void loadProject() { if (projectRunning) { /*setProgressMode(true); DialogResponse response = Dialogs.showConfirmDialog(null, "Do you want to save your current project before starting a new one?", "Save Current Project?", "SNP View"); if (DialogResponse.YES.equals(response)){ boolean saved = saveProject();/*from ww w . ja va2 s . c om*/ if (! saved){ setProgressMode(false); return; }else{ Dialogs.showInformationDialog(null, projectFile.getName() + " saved sucessfully", "Save Successful", "SNP View"); } }else if (DialogResponse.CANCEL.equals(response)){ setProgressMode(false); return; }*/ } loadProjectButton.setDisable(true); newProjectButton.setDisable(true); FileChooser fileChooser = new FileChooser(); fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("SNP Viewer Projects", "*.svproj")); fileChooser.setTitle("Open SNP Viewer Project (.svproj) file"); //setProgressMode(false); File loadFile = fileChooser.showOpenDialog(mainWindow); loadProjectButton.setDisable(false); newProjectButton.setDisable(false); if (loadFile != null) { try { ObjectInputStream is = new ObjectInputStream( new BufferedInputStream(new FileInputStream(loadFile))); try { projectFile = null; projectLabel.setText("Project: none"); chromSplitPane.getItems().clear(); labelSplitPane.getItems().clear(); clearDragSelectRectangle(); savedRegions.clear(); savedRegionsDisplay.clear(); savedRegionsReference.clear(); selectionOverlayPane.getChildren().clear(); selectionOverlayPane.getChildren().add(dragSelectRectangle); resetObservables(); genomeVersion = ""; qualityFilter = null; noFilteringRadio.setSelected(true); chromosomeSelector.getItems().clear(); projectFile = (File) is.readObject();//get rid of this? projectFile = loadFile;//allow relative referencing ArrayList<Color> loadedColors = new ArrayList<>(); ArrayList<SnpFile> tempAff = new ArrayList<>(); ArrayList<SnpFile> tempUn = new ArrayList<>(); tempAff.addAll((ArrayList<SnpFile>) is.readObject()); tempUn.addAll((ArrayList<SnpFile>) is.readObject()); ArrayList<SnpFile> tempBoth = new ArrayList<>(); tempBoth.addAll(tempAff); tempBoth.addAll(tempUn); genomeVersion = (String) is.readObject(); qualityFilter = (Double) is.readObject(); buildLabel.setText(genomeVersion); snpViewSaveDirectory = (File) is.readObject(); savedRegions = (ArrayList<RegionSummary>) is.readObject(); String projectName = projectFile.getName().replaceAll(".svproj", ""); if (!snpViewSaveDirectory.exists()) { snpViewSaveDirectory = new File( projectFile.getParentFile() + "/" + projectName + " SNP Viewer files"); if (!snpViewSaveDirectory.exists()) { DialogResponse response = Dialogs.showErrorDialog(null, "Can't find project directory (" + snpViewSaveDirectory.getName() + ") - do you " + "want to try to find it?", "Project directory " + "not found", "SnpViewer", Dialogs.DialogOptions.YES_NO); if (DialogResponse.YES.equals(response)) { DirectoryChooser dirChooser = new DirectoryChooser(); dirChooser.setTitle("Locate Project Folder"); snpViewSaveDirectory = dirChooser.showDialog(mainWindow); if (snpViewSaveDirectory == null) { returnToInitialState(); return; } } else { returnToInitialState(); return; } } } boolean check = checkProjectFolder(snpViewSaveDirectory, tempBoth); if (!check) { Dialogs.showErrorDialog(null, "Corrupt project" + " folder - missing files.", "Invalid " + "project folder.", "SnpViewer"); returnToInitialState(); return; } for (Color c : colorComp) { String colorString = (String) is.readObject(); loadedColors.add(Color.valueOf(colorString)); } for (int ci = 0; ci < loadedColors.size(); ci++) { colorComponantSelector.getSelectionModel().clearAndSelect(ci); colorPicker.setValue(loadedColors.get(ci)); colorPicker.fireEvent(new ActionEvent()); } affObserve.addAll(tempAff); unObserve.addAll(tempUn); colorComponantSelector.getSelectionModel().selectFirst(); colorComp.clear(); colorComp.addAll(loadedColors); is.close(); setQualityLabel(); checkQualitySelection(); saveProject(); projectLabel.setText("Project: " + projectFile.getName()); //addToChromosomeSelector(affFiles); //addToChromosomeSelector(unFiles); if (!chromosomeSelector.getItems().isEmpty()) { chromosomeSelector.getSelectionModel().selectFirst(); } if (chromosomeSelector.isDisabled()) { chromosomeSelector.setDisable(false); } //setProgressMode(false); if (affObserve.isEmpty() && unObserve.isEmpty()) { resetView(); } projectRunning = true; } catch (IOException | ClassNotFoundException ex) { resetView(); projectLabel.setText("Project: none"); savedRegions.clear(); savedRegionsDisplay.clear(); savedRegionsReference.clear(); resetObservables(); genomeVersion = ""; qualityFilter = null; noFilteringRadio.setSelected(true); chromosomeSelector.getItems().clear(); ex.printStackTrace(); Dialogs.showErrorDialog(null, "Could not load project file", "Load Failed", "SNP Viewer", ex); } } catch (IOException ex) { resetView(); projectLabel.setText("Project: none"); savedRegions.clear(); savedRegionsDisplay.clear(); savedRegionsReference.clear(); resetObservables(); genomeVersion = ""; qualityFilter = null; noFilteringRadio.setSelected(true); chromosomeSelector.getItems().clear(); ex.printStackTrace(); Dialogs.showErrorDialog(null, "Could not load project file - IO error", "Load Failed", "SNP Viewer", ex); } } }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * *//* w ww .ja va 2 s. c o m*/ private void modeleCharger() throws IOException { FileChooser repertChoix = new FileChooser(); FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("fichier panoVisu (*.tpl)", "*.tpl"); repertChoix.getExtensionFilters().add(extFilter); File repert = new File(repertAppli + File.separator + "templates"); repertChoix.setInitialDirectory(repert); File fichtemplate = repertChoix.showOpenDialog(stPrincipal); if (fichtemplate != null) { FileReader fr; try { fr = new FileReader(fichtemplate); List<String> texte = new ArrayList<>(); BufferedReader br = new BufferedReader(fr); String ligneTexte; while ((ligneTexte = br.readLine()) != null) { texte.add(ligneTexte); } System.out.println(texte); gestionnaireInterface.setTemplate(texte); gestionnaireInterface.afficheTemplate(); } catch (FileNotFoundException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } }