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; } } }
@FXML void exportJson() { FileChooser fileChooser = new FileChooser(); fileChooser.setInitialDirectory(Preferences.getPath("lastDir").toFile()); fileChooser.setTitle("Export plain text"); fileChooser.getExtensionFilters().addAll( new ExtensionFilter("JSON files", "*.json"), new ExtensionFilter("All files", "*")); File selected = fileChooser.showSaveDialog(stage); if (selected != null) { try { Preferences.setPath("lastDir", selected.toPath().getParent()); byte[] jsonData = ProjectSerializer.toBytes(project, ImageType.BASE64); FileUtils.writeByteArrayToFile(selected, jsonData); } catch (Exception e) { showError("Error while exporting", e); } } }
public void handleSelectImage(MouseEvent mouseEvent) { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle(imageChooserTitle); fileChooser.getExtensionFilters().add(new ExtensionFilter("PNG", "*.png")); final File file = fileChooser .showOpenDialog(((Node) mouseEvent.getSource()).getScene().getWindow()); if (file == null) { return; } try { final byte[] image = ImageUtils.readImage(file); model.imageRaw.set(image); } catch (IOException e) { e.printStackTrace(); } }
public static File chooseFile(){ FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("��ѡ���ļ�"); if(justVisitedDir == null) { // ���ó�ʼĿ¼ fileChooser.setInitialDirectory(new File(System.getProperty("user.home"))); } else { fileChooser.setInitialDirectory(justVisitedDir); } fileChooser.getExtensionFilters().addAll(new ExtensionFilter[]{new ExtensionFilter("Image Files", new String[]{"*.png", "*.jpg", "*.jpeg", "*.gif", "*.bmp"}), new ExtensionFilter("JPG", new String[]{"*.jpg"}), new ExtensionFilter("JPEG", new String[]{"*.jpeg"}), new ExtensionFilter("BMP", new String[]{"*.bmp"}), new ExtensionFilter("PNG", new String[]{"*.png"}), new ExtensionFilter("GIF", new String[]{"*.gif"})}); File file = fileChooser.showOpenDialog(null); if(file != null){ justVisitedDir = file.getParentFile(); } return file; }
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; } }
private HBox createBrowserField() { HBox browseFieldBox = new HBox(5); dirField = new TextField(); dirField.setId("DirectoryField"); dirField.textProperty().addListener((observable, oldValue, newValue) -> updateOKButton()); HBox.setHgrow(dirField, Priority.ALWAYS); Button browseButton = FXUIUtils.createButton("browse", "Browse directory", true, "Browse"); FileSelectionHandler browserListener; String fileType = fileSelectionInfo.getFileType(); if (fileType != null) { browserListener = new FileSelectionHandler(this, new ExtensionFilter(fileType, Arrays.asList(fileSelectionInfo.getExtensionFilters())), this, null, fileSelectionInfo.getTitle()); } else { browserListener = new FileSelectionHandler(this, null, this, null, fileSelectionInfo.getTitle()); browserListener.setMode(FileSelectionHandler.DIRECTORY_CHOOSER); } browserListener.setPreviousDir(new File(System.getProperty(Constants.PROP_PROJECT_DIR, ProjectLayout.projectDir))); browseButton.setOnAction(browserListener); Label label = createLabel("Name: "); label.setMinWidth(Region.USE_PREF_SIZE); label.setId("FileSelectedLabel"); browseFieldBox.getChildren().addAll(label, dirField, browseButton); VBox.setMargin(browseFieldBox, new Insets(5, 5, 5, 5)); return browseFieldBox; }
/** * Load flight plans from file * @param flightZoneView * @param btnText * @param stage * @return */ Button makeFlightPickerButton(final FlightZoneView flightZoneView, String btnText, Stage stage){ Button btnFlights = createButton(btnText, 120); btnFlights.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(final ActionEvent e) { // File file = fileChooser.showOpenDialog(stage); FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Flight plan (xml)"); fileChooser.getExtensionFilters().addAll( new ExtensionFilter("XML Files", "*.xml")); File selectedFile = fileChooser.showOpenDialog(stage); if (selectedFile != null) { System.out.println("Selected " + selectedFile); flightZoneView.flightManager.loadFlightFromXML(selectedFile.toString()); } } }); return btnFlights; }
@FXML void exportHTML() { FileChooser fileChooser = new FileChooser(); fileChooser.setInitialDirectory(Preferences.getPath("lastDir").toFile()); fileChooser.setTitle("Export HTML"); fileChooser.getExtensionFilters().addAll( new ExtensionFilter("HTML files", "*.html", ".htm"), new ExtensionFilter("All files", "*")); File selected = fileChooser.showSaveDialog(stage); if (selected != null) { try { Preferences.setPath("lastDir", selected.toPath().getParent()); String text = project.getTemplate().render(project, ImageType.BASE64); FileUtils.writeStringToFile(selected, text, Charset.forName("UTF-8")); } catch (Exception e) { showError("Error while exporting", e); } } }
@FXML void importJson() { if (!isUserSure("Import project")) { return; } FileChooser fileChooser = new FileChooser(); fileChooser.setInitialDirectory(Preferences.getPath("lastDir").toFile()); fileChooser.setTitle("Import project"); fileChooser.getExtensionFilters().addAll( new ExtensionFilter("JSON file", "*.json"), new ExtensionFilter("All files", "*")); File selected = fileChooser.showOpenDialog(stage); if (selected != null) { try { Preferences.setPath("lastDir", selected.toPath().getParent()); FileReader reader = new FileReader(selected); flushDataStorage(); replaceProject(ProjectSerializer.fromReader(reader, ImageType.BASE64)); reader.close(); } catch (Exception e) { showError("Couldn't import file", e); } } }
@FXML void openProject() { if (!isUserSure("Open project")) { return; } FileChooser fileChooser = new FileChooser(); fileChooser.setInitialDirectory(Preferences.getPath("lastDir").toFile()); fileChooser.setTitle("Open project"); fileChooser.getExtensionFilters().addAll( new ExtensionFilter("CYOA Studio Project", "*.cyoa"), new ExtensionFilter("All files", "*")); File selected = fileChooser.showOpenDialog(stage); if (selected != null) { try { Preferences.setPath("lastDir", selected.toPath().getParent()); flushDataStorage(); replaceProject(ProjectSerializer.readFromZip(selected.toPath())); saveLocation = selected.toPath(); } catch (Exception e) { showError("Couldn't open file", e); } } }
private boolean selectSaveLocation() { FileChooser fileChooser = new FileChooser(); fileChooser.setInitialDirectory(Preferences.getPath("lastDir").toFile()); fileChooser.setTitle("Save"); fileChooser.getExtensionFilters().addAll( new ExtensionFilter("CYOA Studio Project", "*.cyoa"), new ExtensionFilter("All files", "*")); File selected = fileChooser.showSaveDialog(stage); if (selected == null) { return false; } else { Preferences.setPath("lastDir", selected.toPath().getParent()); saveLocation = selected.toPath(); return true; } }
@FXML void templateFromFile() { FileChooser fileChooser = new FileChooser(); fileChooser.setInitialDirectory(Preferences.getPath("lastTemplateDir").toFile()); fileChooser.setTitle("Import template"); fileChooser.getExtensionFilters().addAll( new ExtensionFilter("CYOA Studio Template", "*.cyoatemplate"), new ExtensionFilter("All files", "*")); File selected = fileChooser.showOpenDialog(stage); if (selected != null) { try { Preferences.setPath("lastTemplateDir", selected.toPath().getParent()); Path tempDirectory = Files.createTempDirectory(null); ZipUtil.unpack(selected, tempDirectory.toFile()); loadTemplate(tempDirectory); FileUtils.deleteDirectory(tempDirectory.toFile()); } catch (Exception e) { showError("Could not load template", e); } } }
public void selectmultifiles(ActionEvent event) { FileChooser fc = new FileChooser(); // fc.setInitialDirectory(new File("C:\\PdfBox_Examples")); fc.getExtensionFilters().addAll(new ExtensionFilter("PDF Files", "*.pdf")); selectedFiles = fc.showOpenMultipleDialog(null); // FIX - Repeating files in list if ReADDED if (selectedFiles != null) { for (int i = 0; i < selectedFiles.size(); i++) { fileslist.getItems().add(selectedFiles.get(i).getAbsolutePath()); mylist.add(selectedFiles.get(i).getAbsolutePath()); NOOFFILES++; } } else { // Provide Error in window System.out.println("Invalid File"); } }
/** * Process install a plugin. */ @FXThread private void processAdd() { GAnalytics.sendPageView("PluginChooseDialog", null, "/dialog/PluginChooseDialog"); GAnalytics.sendEvent(GAEvent.Category.DIALOG, GAEvent.Action.DIALOG_OPENED, "PluginChooseDialog"); final FileChooser chooser = new FileChooser(); chooser.setTitle(Messages.PLUGINS_DIALOG_FILE_CHOOSER_TITLE); chooser.setSelectedExtensionFilter(new ExtensionFilter(Messages.PLUGINS_DIALOG_FILE_CHOOSER_FILTER, "*.zip")); chooser.setInitialDirectory(new File(System.getProperty("user.home"))); final File result = chooser.showOpenDialog(getDialog()); if (result == null) { return; } PLUGIN_MANAGER.installPlugin(result.toPath()); refreshPlugins(); }
public void saveFile() throws IOException { if (filePresent == true) { // save BufferedWriter out = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(currentFile.getAbsolutePath()), "UTF-8")); try { String ls = System.getProperty("line.separator"); String text = textField.getText().replaceAll("\n", ls); out.write(text); } finally { out.close(); } } else { // save as FileChooser fileChooser = new FileChooser(); FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("TXT files (*.txt)", "*.txt"); fileChooser.getExtensionFilters().add(extFilter); File file = fileChooser.showSaveDialog(textField.getScene().getWindow()); if (file != null) { SaveFileAction(textField.getText(), file); } } }
public List<String> selectedFiles() { FileChooser fileChooser = new FileChooser(); fileChooser.setInitialDirectory(initialDirectory()); fileChooser.setTitle("Select Files to Import"); // ofx Microsoft Money // qfx Intuit Quicken // qbo Intuit Quick Books // aso Simply Accounting fileChooser.getExtensionFilters().setAll(new ExtensionFilter("Transaction files (*.ofx, *.qfx, *.qbo, *.aso)", ImmutableList.of("*.ofx", "*.qfx", "*.qbo", "*.aso"))); List<File> files = fileChooser.showOpenMultipleDialog(window); if (files == null) { return ImmutableList.of(); } return FluentIterable.from(files).transform(new Function<File, String>() { @Override public String apply(File input) { return checkNotNull(input).getPath(); } }).toSortedList(Ordering.natural()); }
private void initialize () { fileChooser = new VoogaFileChooser(); fileChooser.setInitialDirectory(new File("resources/sound/")); ResourceBundle extensions = VoogaBundles.extensionProperties; for (String key : extensions.keySet()) { if (extensions.getString(key).equalsIgnoreCase("AUDIO")) { fileChooser.addFilters(new ExtensionFilter("(" + key + ")", "*." + key)); } } file = new Text(); browse = new ButtonMaker().makeButton("Browse", e -> { try { file.setText(fileChooser.launch()); } catch (Exception e1) { VoogaAlert alert = new VoogaAlert(e1.getMessage()); alert.showAndWait(); } }); node = generateHBox(new Text("Sound Path"), browse, file); }
/** * 템플릿 파일 open * * @작성자 : KYJ * @작성일 : 2017. 9. 1. */ @FXML public void miOpenTemplates() { File file = FxUtil.showFileOpenDialog(FxUtil.getWindow(this), c -> { c.getExtensionFilters() .add(new ExtensionFilter("XLST Template files (*.gxml)", GargoyleExtensionFilters.EXTENSION_COMMONS + "gxml")); }); String cont = FileUtil.readFile(file, LoadFileOptionHandler.getDefaultHandler()); JSONObject json = ValueUtil.toJSONObject(cont); Object xmlObj = json.get("xmlData"); if (ValueUtil.isNotEmpty(xmlObj)) { xeXmlData.setText(xmlObj.toString()); } Object xlstObj = json.get("xsltData"); if (ValueUtil.isNotEmpty(xlstObj)) { xeXsltData.setText(xlstObj.toString()); } }
/***********************************************************************************/ /* 이벤트 구현 */ @FXML public void btnBrowseOnMouseClick() { File selectedFile = DialogUtil.showFileDialog(this.getScene().getWindow(), chooser -> { String property = System.getProperty("user.home"); String pathname = String.join(File.separator, property, "AppData", "Local", "SceneBuilder"); File file = new File(pathname); if (!file.exists()) file = new File(property); chooser.setTitle("Scenebuilder Location"); chooser.setInitialFileName("SceneBuilder.exe"); chooser.setInitialDirectory(file); chooser.setSelectedExtensionFilter(new ExtensionFilter(GargoyleExtensionFilters.EXE_NAME, GargoyleExtensionFilters.EXE)); }); if (selectedFile != null && selectedFile.exists()) { txtLocation.setText(selectedFile.getAbsolutePath()); } }
public void miOenOnAction(ActionEvent e) { File showFileDialog = DialogUtil.showFileDialog(/*SharedMemory.getPrimaryStage()*/ null, choser -> { /*마지막에 선택한 경로를 자동선택하는 기능이 추가되었으므로 기본경로 선택 처리는 없앰.*/ // String dir = System.getProperty("user.home"); // choser.setInitialDirectory(new File(dir)); choser.getExtensionFilters().add(new ExtensionFilter(GargoyleExtensionFilters.SQL_NAME, GargoyleExtensionFilters.SQL)); // choser.getExtensionFilters().add(new ExtensionFilter("SQL files (*.sql)", "*.sql")); }); //선택한 파일이 정상적으로 선택된 경우는 null이 아님. if (showFileDialog != null) { String fileContent = FileUtil.readFile(showFileDialog, new LoadFileOptionHandler()); if (fileContent != null /*공백여부는 체크안함. 파일 내용에 실제 공백이 포함될 수 있으므로...*/) { setTxtSql(fileContent); setText(showFileDialog.getName()); } } e.consume(); }
public void onOpen() { FileChooser fileChooser = new FileChooser(); fileChooser.setInitialDirectory(new File(getLastDirectory())); fileChooser.getExtensionFilters().addAll( new FileChooser.ExtensionFilter("All (*.*)", "*.*"), new FileChooser.ExtensionFilter("Graph Markup Language (*.graphml)", "*.graphml") ); // add export-filters to list of extensions for (String format : ImportFilterManager.getImportFilterClasses()) { ImportFilterDescription descr = ImportFilterManager.getImportFilterDescription(format); ExtensionFilter filter = new FileChooser.ExtensionFilter( descr.name() + " (*." + descr.fileExtension() + ")", "*." + descr.fileExtension()); fileChooser.getExtensionFilters().add(filter); } fileChooser.setInitialFileName("*.*"); fileChooser.setTitle("Open File"); List<File> list = fileChooser.showOpenMultipleDialog(stage); if (list != null) { setLastDirectory(list.get(0)); for (File file : list) doOpenFile(file); } }
/** * Opens a file chooser to choose the file to tail, and starts tailing the selected file. */ @FXML public void openFile() { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Open Log File"); fileChooser.getExtensionFilters() .add(new ExtensionFilter("Log files (*.txt, *.log, *.out)", "*.txt", "*.log", "*.out")); fileChooser.getExtensionFilters().add(new ExtensionFilter("All files", "*.*")); File file = fileChooser.showOpenDialog(mainPane.getScene().getWindow()); if (file != null) { try { startTailingFile(file); } catch (FileNotFoundException e) { ErrorDialog.selectedFileNotFound(file.getPath()); } } }
/** * Select the Bitwig executable. */ private void selectDAWExecutable () { final FileChooser chooser = new FileChooser (); chooser.setTitle ("Select the DAW executable file"); if (OperatingSystem.get () == OperatingSystem.WINDOWS) { final ExtensionFilter filter = new ExtensionFilter ("Executable", "*.exe"); chooser.getExtensionFilters ().add (filter); } final File file = chooser.showOpenDialog (this.stage); if (file != null) this.applicationCommand.setText (file.getAbsolutePath ()); }
/** * Used to import a new .gfa file. It will open up a file explorer to browse to your file. * It will build the recently opened file submenu and the existing submenu accordingly. * It also checks if the import is really new. If it is, then getting an existing database * should return null and it will start the import, else it will open it as an existing file. * @param actionEvent An Event representing some type of action */ public void importNew(final ActionEvent actionEvent) { final FileChooser fileExplorer = new FileChooser(); fileExplorer.getExtensionFilters().addAll(new ExtensionFilter("gfa files", "*.gfa")); File file = fileExplorer.showOpenDialog(verticalBox.getScene().getWindow()); if (file != null) { RecentHandler recent = new RecentHandler(); final String fileName = FilenameUtils.removeExtension(file.getName()); final String dbPath = System.getProperty("user.dir") + File.separator + "db" + File.separator + fileName; if (new ExistingHandler().buildExistingMap().get(fileName) == null) { recent.buildRecent(dbPath, fileName); ImportHandler importer = new ImportHandler( Launcher.getStage(), file.getAbsolutePath(), fileName); importer.startImport(); updateExisting(); } else { openExisting(dbPath, fileName); } } }
@SuppressWarnings("unused") @FXML void onCmdChooseFileDestination(ActionEvent evt) { FileChooser chooser = new FileChooser(); List<ExtensionFilter> extensionFilters = new ArrayList<>(); CertWriter writer = this.ctlFormatOption.getValue(); if (writer != null) { extensionFilters.add(new ExtensionFilter(writer.fileType(), writer.fileExtensionPatterns())); } extensionFilters.add(FileChooserHelper.filterFromString(CertExportI18N.formatSTR_FILTER_ALLFILES())); chooser.getExtensionFilters().addAll(extensionFilters); chooser.setSelectedExtensionFilter(extensionFilters.get(0)); chooser.setInitialDirectory(this.preferenceInitalDirectory.getValueAsFile()); File fileSource = chooser.showSaveDialog(getUI()); if (fileSource != null) { this.ctlFileDestinationInput.setText(fileSource.getAbsolutePath()); this.preferenceInitalDirectory.putValueFromFile(fileSource.getParentFile()); syncPreferences(); } }
@SuppressWarnings("unused") @FXML void onCmdChooseFileSource(ActionEvent evt) { FileChooser chooser = new FileChooser(); List<ExtensionFilter> extensionFilters = new ArrayList<>(); extensionFilters.add(FileChooserHelper.filterFromString(CertImportI18N.formatSTR_FILTER_ALLFILES())); for (CertReader reader : CertReaders.REGISTERED.providers()) { extensionFilters.add(new ExtensionFilter(reader.fileType(), reader.fileExtensionPatterns())); } chooser.getExtensionFilters().addAll(extensionFilters); chooser.setSelectedExtensionFilter(extensionFilters.get(0)); chooser.setInitialDirectory(this.preferenceInitalDirectory.getValueAsFile()); File fileSource = chooser.showOpenDialog(getUI()); if (fileSource != null) { this.ctlFileSourceInput.setText(fileSource.getAbsolutePath()); this.preferenceInitalDirectory.putValueFromFile(fileSource.getParentFile()); syncPreferences(); validateAndReloadFileSource(); } }
private List<ExtensionFilter> getFilters() { // 示例:"Model File|*.j3o|*.obj|*.mesh.xml,All Files|*.*" String[] filters = this.featureHelper.getAsArray(FEATURE_FILTERS); if (filters != null && filters.length > 0) { List<ExtensionFilter> efs = new ArrayList(filters.length); for (String f : filters) { if (f == null || f.trim().equals("")) { continue; } List<String> itemList = new ArrayList(Arrays.asList(f.split("\\|"))); String des = itemList.remove(0); efs.add(new ExtensionFilter(des, itemList)); } return efs; } return Collections.EMPTY_LIST; }
/** * Triggered by the inspect button. Opens a dialogue for the user to decide the output file for the report, then executes the report, writing the * output to that file. * * @throws FileNotFoundException * If the story file or report spec file no longer exist. */ @FXML private void inspect() { final FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Choose Report Output File"); fileChooser.setInitialDirectory(this.selectedStoryFile.getParentFile()); fileChooser.setInitialFileName(getDefaultReportOutputFile().getName()); fileChooser.getExtensionFilters().add(new ExtensionFilter("Microsoft Word Open XML Format Document", "*.docx")); final File reportOutputFile = fileChooser.showSaveDialog(ControllerUtils.getStage(this.reportNameLabel)); if (reportOutputFile != null) { try { executeReport(reportOutputFile); } catch (final FileNotFoundException e) { final Alert alert = new Alert(AlertType.ERROR, "File not found: " + e.getLocalizedMessage(), ButtonType.OK); alert.showAndWait(); } } }
/** * Allows the user to choose an arbitrary *.resx file and asks them to choose out of the available locales for * Left * and Right in the view. */ public void fileChoosing() { project.hide(); view.hide(); final Path chosenFile = DIALOG.chooseFile("Select a resx or thp file", new ExtensionFilter("Resource file", "*.resx"), new ExtensionFilter("TranslationHelper Project file", "*.thp")); if (chosenFile == null) { project.show(); return; } if (chosenFile.getFileName().toString().endsWith(".thp")) { project.loadProject(chosenFile); project.show(); } else { view.loadFiles(chosenFile); view.show(); view.selectLocale(); } }
/** * Save the current stage under a new name. * */ public void saveStageAs(final File dataDir) { final Stage stage = getStage(); if (stage == null) return; final FileChooser fc = new FileChooser(); fc.setTitle("Save map file"); fc.setInitialDirectory(dataDir); fc.getExtensionFilters().addAll(new ExtensionFilter("Map Files", "*.map")); File r = fc.showSaveDialog(window); if (r != null) { // automatically append .map if the user didn't give an extension final String name = r.getName(); if (name.lastIndexOf('.') == -1) { final File p = r.getAbsoluteFile().getParentFile(); r = new File(p, name + ".map"); } stageFile = r; String n = r.getName(); getStage().name = n.substring(0, n.lastIndexOf('.')); saveStage(dataDir); } }
private void exportData(Map<String, String> data) { FileChooser chooser = new FileChooser(); chooser.setTitle(translate("translate.export")); chooser.setSelectedExtensionFilter(new ExtensionFilter("*.json", "*.json")); File target = chooser.showSaveDialog(stage); if (target == null) return; progressWindow().show(false); CompletableFuture .runAsync(() -> { JSONObject json = new JSONObject(data); try (Writer writer = new OutputStreamWriter(new FileOutputStream(target), "UTF-8")) { writer.write(json.toString()); } catch (IOException e) { throw new UncheckedIOException(e); } }) .handleAsync((result, err) -> { progressWindow().hide(); if (err == null) { lastStoredData = new HashMap<>(data); } else { reportException(err); } return null; }, Platform::runLater); }
@FXML public void browse(ActionEvent evt) { if( logger.isDebugEnabled() ) { logger.debug("[BROWSE]"); } FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Select JARs"); fileChooser.getExtensionFilters().addAll( new ExtensionFilter("JAR Files", "*.jar", "*.zip") ); List<File> selectedFiles = fileChooser.showOpenMultipleDialog(((Button)evt.getSource()).getScene().getWindow()); if( selectedFiles != null ) { lvJARs.getItems().clear(); lvJARs.setItems( FXCollections.observableArrayList(selectedFiles) ); } }
private FileChooser createFileChooser(String title) { String[] extensions = Options.getMarkdownFileExtensions().trim().split("\\s*,\\s*"); FileChooser fileChooser = new FileChooser(); fileChooser.setTitle(title); fileChooser.getExtensionFilters().addAll( new ExtensionFilter(Messages.get("FileEditorTabPane.chooser.markdownFilesFilter"), extensions), new ExtensionFilter(Messages.get("FileEditorTabPane.chooser.allFilesFilter"), "*.*")); String lastDirectory = MarkdownWriterFXApp.getState().get("lastDirectory", null); File file = new File((lastDirectory != null) ? lastDirectory : "."); if (!file.isDirectory()) file = new File("."); fileChooser.setInitialDirectory(file); return fileChooser; }