List of usage examples for javafx.stage FileChooser FileChooser
FileChooser
From source file:com.cdd.bao.editor.EditSchema.java
public void actionFileOpen() { FileChooser chooser = new FileChooser(); chooser.setTitle("Open Schema Template"); if (schemaFile != null) chooser.setInitialDirectory(schemaFile.getParentFile()); File file = chooser.showOpenDialog(stage); if (file == null) return;//from w w w . ja v a 2s . c om try { Schema schema = ModelSchema.deserialise(file); Stage stage = new Stage(); EditSchema edit = new EditSchema(stage); edit.loadFile(file, schema); stage.show(); } catch (IOException ex) { ex.printStackTrace(); Util.informWarning("Open", "Failed to parse file: is it a valid schema?"); } }
From source file:org.simmi.GeneSetHead.java
License:asdf
private void importStuff() throws IOException, UnavailableServiceException { boolean fail = true; /*try {// w w w.j a v a 2 s. co m FileOpenService fos = (FileOpenService)ServiceManager.lookup("javax.jnlp.FileOpenService"); FileContents fc = fos.openFileDialog(null, null); is = fc.getInputStream(); } catch( Exception e ) { fail = true; }*/ Path zipp = null; if (fail && zipp == null) { FileChooser fc = new FileChooser(); File f = fc.showOpenDialog(app.getOwner()); if (f != null) zipp = f.toPath(); } //if( is != null ) { /*ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] bab = new byte[1024]; int rd = is.read( bab ); while( rd > 0 ) { baos.write(bab, 0, rd); rd = is.read( bab ); } baos.close(); zipf = baos.toByteArray();*/ /*ZipInputStream zipm = new ZipInputStream( new ByteArrayInputStream( zipf ) ); ZipEntry ze = zipm.getNextEntry(); while( ze != null ) { String zname = ze.getName(); if( zname.equals("unresolved.blastout") ) { unresolvedmap = loadunresolvedmap( new InputStreamReader( zipm ) ); } else if( zname.equals("namemap.txt") ) { namemap = loadnamemap( new InputStreamReader( zipm ) ); } else if( ze.getName().equals("designations.txt") ) { designations = loadDesignations( new InputStreamReader(zipm), deset ); } else if( ze.getName().equals("plasmids.txt") ) { plasmids = loadPlasmids( new InputStreamReader(zipm) ); } ze = zipm.getNextEntry(); } if( designations == null ) designations = new TreeMap<String,String>(); //List<Set<String>> uclusterlist = null;*/ if (zipp != null) { geneset.loadStuff(zipp); //syncolorcomb = new JComboBox(); syncolorcomb.getItems().clear(); syncolorcomb.getItems().add(""); for (String spec : geneset.speccontigMap.keySet()) { syncolorcomb.getItems().add(spec); } syncolorcomb.getItems().add("All"); /* * is = GeneSet.class.getResourceAsStream(""); Map<String,String> komap * = koMapping( new FileReader("/home/sigmar/asgard-bio/data/ko"), * funclist, genelist ); for( Function f : funclist ) { if( * komap.containsKey( f.ec ) ) { for( String gn : f.geneentries ) { Gene * g = refmap.get(gn); if( g.keggid == null ) g.keggid = * komap.get(f.ec); } } } */ geneset.updateShareNum(geneset.specList); Set<String> allecs = new HashSet<>(); for (Function f : geneset.funclist) { if (f.getEc() != null) allecs.add(f.getEc()); } for (String val : geneset.pathwaymap.keySet()) { Set<String> set = geneset.pathwaymap.get(val); for (String s : set) { if (allecs.contains(s)) { combo.getItems().add(val); break; } } } Set<String> set = new TreeSet<>(); for (Gene g : geneset.genelist) { Tegeval tv = g.tegeval; if (tv.eval <= 0.00001 && tv.teg != null && tv.teg.startsWith("[") && tv.teg.endsWith("]")) set.add(tv.teg); } for (String sp : set) { specombo.getItems().add(sp); } if (geneset.uclusterlist != null) geneset.clusterMap = Serifier.initClusterNew(geneset.uclusterlist, null, null); //table.tableChanged( new TableModelEvent( table.getModel() ) ); //ftable.tableChanged( new TableModelEvent( ftable.getModel() ) ); //table.setModel( nullmodel ); //ftable.setModel( nullmodel ); //table.setModel( groupModel ); //ftable.setModel( ftablemodel ); //ftable.setItems( geneset.f); for (String spec : geneset.specList) { TableColumn<GeneGroup, Teginfo> speccol = new TableColumn(spec); //speccol.getStyleClass().add("tabstyle"); speccol.setCellFactory(cell -> { final TableCell<GeneGroup, Teginfo> tc = new TableCell<GeneGroup, Teginfo>() { @Override protected void updateItem(Teginfo item, boolean empty) { super.updateItem(item, empty); if (item == null || item.toString().length() == 0 || empty) { setText(null); setStyle(""); //getStyleClass().remove("tabcellstyle"); } else { setText(item.toString()); cellRender(this, item, 0); //getStyleClass().add("tabcellstyle"); /*if( (this.getTableRow() != null && getTableRow().isSelected()) || isSelected() ) { //setTextFill( javafx.scene.paint.Color.WHITE ); setStyle("-fx-background-color: darkgreen"); } else { //setTextFill( javafx.scene.paint.Color.BLACK ); setStyle("-fx-background-color: green"); }*/ } } }; return tc; }); speccol.setCellValueFactory(cellValue -> { GeneGroup gg = cellValue.getValue(); Teginfo tes = gg.getTes(spec); return new ReadOnlyObjectWrapper(tes); //return new SimpleStringProperty( tes != null ? tes.toString() : "" ); //Teginfo ret = geneset.getGroupTes( cellValue.getValue(), spec ); //return new ObservableValue<String>( ret.toString() ); //return ret; }); table.getColumns().add(speccol); TableColumn<Gene, Teg> gspeccol = new TableColumn(spec); gspeccol.setComparator((o1, o2) -> { if (o1 == null) { if (o2 == null) { return 0; } else return -1; } else if (o1 instanceof Tegeval) { if (o2 == null || o2 instanceof Teginfo) { return 1; } } else { if (o2 == null) { return 1; } else if (o2 instanceof Tegeval) { return -1; } } return o1.compareTo(o2); }); gspeccol.setCellFactory(cell -> { final TableCell<Gene, Teg> tc = new TableCell<Gene, Teg>() { @Override protected void updateItem(Teg item, boolean empty) { super.updateItem(item, empty); if (item == null || item.toString().length() == 0 || empty) { setText(""); setStyle(""); } else { boolean render = cellRenderGene(this, item); setText(item.toString()); if (!render) setStyle(""); //getStyleClass().add("tabcellstyle"); /*if( (this.getTableRow() != null && getTableRow().isSelected()) || isSelected() ) { //setTextFill( javafx.scene.paint.Color.WHITE ); setStyle("-fx-background-color: white"); } else { //setTextFill( javafx.scene.paint.Color.BLACK ); setStyle("-fx-background-color: black"); }*/ } } }; return tc; }); gspeccol.setCellValueFactory(cellValue -> { Gene g = cellValue.getValue(); //Teginfo tes = g.tegeval;//getTes( spec ); if (spec.equals(g.getSpecies())) { return new ReadOnlyObjectWrapper(g.tegeval); } else { GeneGroup gg = g.getGeneGroup(); Set<String> specset = gg.getSpecies(); if (specset.contains(spec)) { Teginfo ti = gg.getGenes(spec); return new ReadOnlyObjectWrapper(ti); } } //return new SimpleStringProperty( tes != null ? tes.toString() : "" ); //Teginfo ret = geneset.getGroupTes( cellValue.getValue(), spec ); //return new ObservableValue<String>( ret.toString() ); //return ret; return null; }); /*gspeccol.setCellValueFactory( cellValue -> { return new SimpleStringProperty( cellValue.getValue().toString() ); //Teginfo ret = geneset.getGroupTes( cellValue.getValue(), spec ); //return new ObservableValue<String>( ret.toString() ); //return ret; });*/ gtable.getColumns().add(gspeccol); } ObservableList<Function> ofunc = FXCollections.observableList(geneset.funclist); ffilteredData = new FilteredList<>(ofunc, p -> true); fsortedData = new SortedList<>(ffilteredData); fsortedData.comparatorProperty().bind(ftable.comparatorProperty()); ftable.setItems(fsortedData); ObservableList<GeneGroup> ogenegroup = FXCollections.observableList(geneset.allgenegroups); filteredData = new FilteredList<>(ogenegroup, p -> true); sortedData = new SortedList<>(filteredData); sortedData.comparatorProperty().bind(table.comparatorProperty()); table.setItems(sortedData); ObservableList<Gene> ogene = FXCollections.observableList(geneset.genelist); gtable.setItems(ogene); int me = 0; int mu = 0; for (Gene g : geneset.genelist) { if (g.getGeneGroup() != null) me++; else mu++; } System.err.println(me + " " + mu); } String userhome = System.getProperty("user.home"); File f = new File(userhome); File idf = new File(f, "idspec.txt"); BufferedWriter bw = new BufferedWriter(new FileWriter(idf)); //Files.newBufferedWriter(idf.toPath(), OpenOption.); for (String id : geneset.refmap.keySet()) { Gene g = geneset.refmap.get(id); bw.write(id + "\t" + g.getSpecies() + "\n"); } bw.close(); }
From source file:com.cdd.bao.editor.EditSchema.java
public void actionFileExportDump() { if (!Vocabulary.globalInstance().isLoaded()) return;/* w w w . j a v a 2 s . com*/ pullDetail(); FileChooser chooser = new FileChooser(); chooser.setTitle("Export Schema Dump"); if (schemaFile != null) chooser.setInitialDirectory(schemaFile.getParentFile()); chooser.setInitialFileName("vocab.dump"); File file = chooser.showSaveDialog(stage); if (file == null) return; // when overwriting a file, bring up a preview that shows the differences between before & after, and asks for // confirmation before replacing it if (file.exists()) { try { new CompareVocabTree(file, stack.getSchema()).show(); } catch (Exception ex) { ex.printStackTrace(); } return; } Schema[] schemaList = new Schema[] { stack.getSchema() }; SchemaVocab sv = new SchemaVocab(Vocabulary.globalInstance(), schemaList); Util.writeln("-------------------------"); sv.debugSummary(); Util.writeln("-------------------------"); try { OutputStream ostr = new FileOutputStream(file); sv.serialise(ostr); ostr.close(); } catch (IOException ex) { ex.printStackTrace(); } String msg = "Written to [" + file.getAbsolutePath() + "]. Size: " + file.length(); Util.informWarning("Export", msg); }
From source file:acmi.l2.clientmod.xdat.Controller.java
@FXML private void saveAs() { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Save"); fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("XDAT (*.xdat)", "*.xdat"), new FileChooser.ExtensionFilter("All files", "*.*")); fileChooser.setInitialFileName(xdatFile.getValue().getName()); if (initialDirectory.getValue() != null && initialDirectory.getValue().exists() && initialDirectory.getValue().isDirectory()) fileChooser.setInitialDirectory(initialDirectory.getValue()); File file = fileChooser.showSaveDialog(editor.getStage()); if (file == null) return;//from w ww . jav a 2 s. c o m this.xdatFile.setValue(file); initialDirectory.setValue(file.getParentFile()); save(); }
From source file:com.cdd.bao.editor.EditSchema.java
public void actionFileMerge() { FileChooser chooser = new FileChooser(); chooser.setTitle("Merge Schema"); if (schemaFile != null) chooser.setInitialDirectory(schemaFile.getParentFile()); File file = chooser.showOpenDialog(stage); if (file == null) return;/*from w ww .ja v a 2 s . c o m*/ Schema addSchema = null; try { addSchema = ModelSchema.deserialise(file); } catch (IOException ex) { ex.printStackTrace(); Util.informWarning("Merge", "Failed to parse file: is it a valid schema?"); return; } List<String> log = new ArrayList<>(); Schema merged = SchemaUtil.mergeSchema(stack.getSchema(), addSchema, log); if (log.size() == 0) { Util.informMessage("Merge", "The merge file is the same: no action."); return; } String text = String.join("\n", log); Dialog<Boolean> confirm = new Dialog<>(); confirm.setTitle("Confirm Merge Modifications"); TextArea area = new TextArea(text); area.setWrapText(true); area.setPrefWidth(700); area.setPrefHeight(500); confirm.getDialogPane().setContent(area); ButtonType btnApply = new ButtonType("Apply", ButtonBar.ButtonData.OK_DONE); confirm.getDialogPane().getButtonTypes().addAll(new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE), btnApply); confirm.setResultConverter(buttonType -> { if (buttonType == btnApply) return true; return null; }); Optional<Boolean> result = confirm.showAndWait(); if (!result.isPresent() || result.get() != true) return; stack.changeSchema(merged, true); rebuildTree(); }
From source file:io.github.mzmine.modules.plots.msspectrum.MsSpectrumPlotWindowController.java
public void handleExportMzML(Event event) { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Export to mzML"); fileChooser.getExtensionFilters().add(new ExtensionFilter("mzML", "*.mzML")); // Remember last directory if (lastSaveDirectory != null && lastSaveDirectory.isDirectory()) fileChooser.setInitialDirectory(lastSaveDirectory); // Show the file chooser File file = fileChooser.showSaveDialog(chartNode.getScene().getWindow()); // If nothing was chosen, quit if (file == null) return;/*w ww . j a va 2 s . c o m*/ // Save the last open directory lastSaveDirectory = file.getParentFile(); final List<MsSpectrum> spectra = new ArrayList<>(); for (MsSpectrumDataSet dataset : datasets) { spectra.add(dataset.getSpectrum()); } // Do the export in a new thread final File finalFile = file; new Thread(() -> { try { // Create a temporary raw data file DataPointStore tmpStore = DataPointStoreFactory.getMemoryDataStore(); RawDataFile tmpRawFile = MSDKObjectBuilder.getRawDataFile("Exported spectra", null, FileType.UNKNOWN, tmpStore); int scanNum = 1; for (MsSpectrumDataSet dataset : datasets) { MsSpectrum spectrum = dataset.getSpectrum(); MsScan newScan; if (spectrum instanceof MsScan) { newScan = MsScanUtil.clone(tmpStore, (MsScan) spectrum, true); } else { MsFunction msf = MSDKObjectBuilder.getMsFunction(MsFunction.DEFAULT_MS_FUNCTION_NAME); newScan = MSDKObjectBuilder.getMsScan(tmpStore, scanNum, msf); } tmpRawFile.addScan(newScan); } MzMLFileExportMethod exporter = new MzMLFileExportMethod(tmpRawFile, finalFile); exporter.execute(); tmpRawFile.dispose(); } catch (Exception e) { MZmineGUI.displayMessage("Unable to export: " + e.getMessage()); e.printStackTrace(); } }).start(); }
From source file:nl.mvdr.umvc3replayanalyser.controller.Umvc3ReplayManagerController.java
/** Action handler to import a single replay manually. */ @FXML/*ww w . ja v a2 s.c om*/ private void handleAddReplayAction() { log.info("Add Replay Manually menu item selected."); FileChooser chooser = new FileChooser(); chooser.setTitle("Add Replay - Ultimate Marvel vs Capcom 3 Replay Manager"); final File selectedFile = chooser.showOpenDialog(getApplicationWindow()); log.info("Selected file: " + selectedFile + "."); if (selectedFile != null) { EditReplayController controller = new EditReplayController(new ReplayDetailsEditedHandler() { /** {@inheritDoc} */ @Override public void handleReplayDetailsEdited(Game game) { addReplay(selectedFile, game); } }); Popups.showEditReplayPopup(controller); } }
From source file:UI.MainStageController.java
/** * <h1>Lets the user choose a file / files to load.</h1> * Distinguishes which filetype is about to be loaded by the user * and calls the associated methods.// w w w .jav a 2 s. c o m * * @param fileType Enum to differentiate which type of file is loaded by the user. */ private void openFiles(FileType fileType) { FileChooser fileChooser = new FileChooser(); String fileChooserTitle = "Load from "; if ((Boolean) UserSettings.userSettings.get("isDefaultFileChooserLocation")) { setDefaultOpenDirectory(fileChooser); } else { fileChooser.setInitialDirectory( new File((String) UserSettings.userSettings.get("defaultFileChooserLocation"))); } switch (fileType) { case taxonId2Count: fileChooser.setTitle(fileChooserTitle + "taxonId2Count file"); break; case readName2TaxonId: fileChooser.setTitle(fileChooserTitle + "readName2TaxonId file"); break; case biomV1: fileChooser.setTitle(fileChooserTitle + "biomV1 file"); break; case biomV2: fileChooser.setTitle(fileChooserTitle + "biomV2 file"); break; case qiime: fileChooser.setTitle(fileChooserTitle + "qiime file"); break; } //Choose the file / files List<File> selectedFiles = fileChooser.showOpenMultipleDialog(getPrimaryStage()); if (selectedFiles != null) { //Keeps every file that has been loaded before in a list to show only one alert //for multiple files ArrayList<String> namesOfAlreadyLoadedFiles = new ArrayList<>(); for (File file : selectedFiles) { String foundFilePath = file.getAbsolutePath(); if (LoadedData.getOpenFiles() != null && LoadedData.getOpenFiles().contains(foundFilePath)) { namesOfAlreadyLoadedFiles.add(file.getName()); } else { switch (fileType) { case taxonId2Count: addId2CountFileToTreeView(file); break; case readName2TaxonId: addReadName2TaxonIdFileToTreeView(file); break; case biomV1: addBiomV1FileToTreeView(file); break; case biomV2: addBiomV2FileToTreeView(file); break; case qiime: //TODO HANDLE METADATA PROVIDED BY QIIME break; } } } //Shows an alert if the user chose to load one or multiple files //that have already been loaded before. if (namesOfAlreadyLoadedFiles.size() != 0) { showFileAlreadyLoadedAlert(namesOfAlreadyLoadedFiles); } } }
From source file:dsfixgui.view.DSPWPane.java
private void initializeEventHandlers() { applySettingsButton.setOnAction(e -> { ui.applyDSPWConfig();//from w w w .j a va 2 s . co m }); restoreDefaultsButton.setOnAction(e -> { ContinueDialog cD = new ContinueDialog(300.0, 80.0, DIALOG_TITLE_RESET, DIALOG_MSG_RESTORE_SETTINGS, DIALOG_BUTTON_TEXTS[2], DIALOG_BUTTON_TEXTS[1]); if (cD.show()) { config.restoreDefaults(); ui.refreshUI(); } }); versionBannerOn.setOnAction(e -> { config.ShowVersionBanner.replace(0, config.ShowVersionBanner.length(), TRUE_FALSE[0]); }); versionBannerOff.setOnAction(e -> { config.ShowVersionBanner.replace(0, config.ShowVersionBanner.length(), TRUE_FALSE[1]); }); overlayOn.setOnAction(e -> { config.ShowOverlay.replace(0, config.ShowOverlay.length(), TRUE_FALSE[0]); }); overlayOff.setOnAction(e -> { config.ShowOverlay.replace(0, config.ShowOverlay.length(), TRUE_FALSE[1]); }); invasionNotifOn.setOnAction(e -> { config.InvasionSoundNotification.replace(0, config.InvasionSoundNotification.length(), TRUE_FALSE[0]); }); invasionNotifOff.setOnAction(e -> { config.InvasionSoundNotification.replace(0, config.InvasionSoundNotification.length(), TRUE_FALSE[1]); }); cheaterNotifOn.setOnAction(e -> { config.CheaterSoundNotification.replace(0, config.CheaterSoundNotification.length(), TRUE_FALSE[0]); }); cheaterNotifOff.setOnAction(e -> { config.CheaterSoundNotification.replace(0, config.CheaterSoundNotification.length(), TRUE_FALSE[1]); }); blockArenaFreezeOn.setOnAction(e -> { config.BlockArenaFreeze.replace(0, config.BlockArenaFreeze.length(), TRUE_FALSE[0]); }); blockArenaFreezeOff.setOnAction(e -> { config.BlockArenaFreeze.replace(0, config.BlockArenaFreeze.length(), TRUE_FALSE[1]); }); nodeCountOn.setOnAction(e -> { config.ShowNodeDbCount.replace(0, config.ShowNodeDbCount.length(), TRUE_FALSE[0]); }); nodeCountOff.setOnAction(e -> { config.ShowNodeDbCount.replace(0, config.ShowNodeDbCount.length(), TRUE_FALSE[1]); }); increaseNodesOn.setOnAction(e -> { config.IncreaseNodeDbLimit.replace(0, config.IncreaseNodeDbLimit.length(), TRUE_FALSE[0]); }); increaseNodesOff.setOnAction(e -> { config.IncreaseNodeDbLimit.replace(0, config.IncreaseNodeDbLimit.length(), TRUE_FALSE[1]); }); dateOn.setOnAction(e -> { config.DisplayDate.replace(0, config.DisplayDate.length(), TRUE_FALSE[0]); }); dateOff.setOnAction(e -> { config.DisplayDate.replace(0, config.DisplayDate.length(), TRUE_FALSE[1]); }); timeOn.setOnAction(e -> { config.DisplayClock.replace(0, config.DisplayClock.length(), TRUE_FALSE[0]); }); timeOff.setOnAction(e -> { config.DisplayClock.replace(0, config.DisplayClock.length(), TRUE_FALSE[1]); }); updateOn.setOnAction(e -> { config.CheckForUpdates.replace(0, config.CheckForUpdates.length(), TRUE_FALSE[0]); }); updateOff.setOnAction(e -> { config.CheckForUpdates.replace(0, config.CheckForUpdates.length(), TRUE_FALSE[1]); }); textAlignmentLeft.setOnAction(e -> { config.TextAlignment.replace(0, config.TextAlignment.length(), DSPW_TEXT_ALIGNMENT_OPTIONS[0]); }); textAlignmentCenter.setOnAction(e -> { config.TextAlignment.replace(0, config.TextAlignment.length(), DSPW_TEXT_ALIGNMENT_OPTIONS[1]); }); textAlignmentRight.setOnAction(e -> { config.TextAlignment.replace(0, config.TextAlignment.length(), DSPW_TEXT_ALIGNMENT_OPTIONS[2]); }); fontSizeField.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldText, String newText) { try { if (!NumberUtils.isParsable(newText) || Integer.parseInt(newText) > 72 || Integer.parseInt(newText) < 15) { fontSizeField.pseudoClassStateChanged(INVALID_INPUT, true); } else { fontSizeField.pseudoClassStateChanged(INVALID_INPUT, false); config.FontSize.replace(0, config.FontSize.length(), "" + Integer.parseInt(newText)); } } catch (NumberFormatException nFE) { ui.printConsole(INPUT_TOO_LARGE); fontSizeField.setText(""); } } }); dllChainButton.setOnAction(e -> { FileChooser dllChooser = new FileChooser(); dllChooser.setTitle(DIALOG_TITLE_DLL); if (ui.getDataFolder() != null) { dllChooser.setInitialDirectory(ui.getDataFolder()); } ExtensionFilter dllFilter = new ExtensionFilter(DLL_EXT_FILTER[0], DLL_EXT_FILTER[1]); dllChooser.getExtensionFilters().add(dllFilter); File dll = dllChooser.showOpenDialog(ui.getStage()); if (dll != null && ui.getDataFolder() != null) { File checkDLL = new File(ui.getDataFolder() + "\\" + dll.getName()); if (!checkDLL.exists()) { AlertDialog aD = new AlertDialog(300.0, 80.0, DIALOG_TITLE_WRONG_FOLDER, DLL_MUST_BE_IN_DATA, DIALOG_BUTTON_TEXTS[0]); } else { if (dll.getName().equals(DSM_FILES[0])) { AlertDialog aD = new AlertDialog(300.0, 80.0, INVALID_DLL, CANT_CHAIN_DLL_WITH_DSM, DIALOG_BUTTON_TEXTS[0]); } else if (dll.getName().equals(DSF_FILES[0])) { AlertDialog aD = new AlertDialog(300.0, 80.0, INVALID_DLL, CANT_CHAIN_DLL_WITH_DSF, DIALOG_BUTTON_TEXTS[0]); } else if (dll.getName().equals(DS_DEFAULT_DLLS[0]) || dll.getName().equals(DS_DEFAULT_DLLS[1]) || dll.getName().equals(DS_DEFAULT_DLLS[2])) { AlertDialog aD = new AlertDialog(300.0, 80.0, INVALID_DLL, CANT_CHAIN_DLL_WITH_DEFAULT, DIALOG_BUTTON_TEXTS[0]); } else if (dll.getName().equals(DSPW_FILES[1]) || dll.getName().equals(DSPW_FILES[4]) || dll.getName().equals(DSPW_FILES[5])) { AlertDialog aD = new AlertDialog(300.0, 80.0, INVALID_DLL, CANT_CHAIN_DSPW_WITH_DSPW, DIALOG_BUTTON_TEXTS[0]); } else { config.d3d9dllWrapper.replace(0, config.d3d9dllWrapper.length(), dll.getName()); dllChainField.setText(dll.getName()); dllChainField.setStyle("-fx-text-fill: black;"); noChainButton.setDisable(false); } } } }); noChainButton.setOnAction(e -> { dllChainField.setText(NONE); noChainButton.setDisable(true); dllChainField.setStyle("-fx-text-fill: gray;"); config.d3d9dllWrapper.replace(0, config.d3d9dllWrapper.length(), NONE); }); banPicker.setOnAction(e -> { config.key_BanPhantom.replace(0, config.key_BanPhantom.length(), keybindsHex.get(keybinds.indexOf(banPicker.getValue()))); }); ignorePicker.setOnAction(e -> { config.key_IgnorePhantom.replace(0, config.key_IgnorePhantom.length(), keybindsHex.get(keybinds.indexOf(ignorePicker.getValue()))); }); toggleOverlayPicker.setOnAction(e -> { config.key_HideOverlay.replace(0, config.key_HideOverlay.length(), keybindsHex.get(keybinds.indexOf(toggleOverlayPicker.getValue()))); }); aboutPicker.setOnAction(e -> { config.key_AboutDSPW.replace(0, config.key_AboutDSPW.length(), keybindsHex.get(keybinds.indexOf(aboutPicker.getValue()))); }); }
From source file:io.github.mzmine.modules.plots.msspectrum.MsSpectrumPlotWindowController.java
public void handleExportMGF(Event event) { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Export to MGF"); fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Mascot Generic Format", "*.mgf")); // Remember last directory if (lastSaveDirectory != null && lastSaveDirectory.isDirectory()) fileChooser.setInitialDirectory(lastSaveDirectory); // Show the file chooser File file = fileChooser.showSaveDialog(chartNode.getScene().getWindow()); // If nothing was chosen, quit if (file == null) return;// w w w . j a va 2s .com // Save the last open directory lastSaveDirectory = file.getParentFile(); final List<MsSpectrum> spectra = new ArrayList<>(); for (MsSpectrumDataSet dataset : datasets) { spectra.add(dataset.getSpectrum()); } // Do the export in a new thread final File finalFile = file; new Thread(() -> { try { MgfFileExportMethod mgfEx = new MgfFileExportMethod(spectra, finalFile); mgfEx.execute(); } catch (Exception e) { MZmineGUI.displayMessage("Unable to export: " + e.getMessage()); e.printStackTrace(); } }).start(); }