Added native file open dialog
@@ -21,14 +21,12 @@ package io.github.mzmine.modules.io.rawdataimport;
import java.awt.Window;
import java.io.File;
import java.util.List;
-
-import javax.swing.JFileChooser;
-import javax.swing.filechooser.FileFilter;
-import javax.swing.filechooser.FileNameExtensionFilter;
+import java.util.concurrent.FutureTask;
import io.github.mzmine.parameters.Parameter;
import io.github.mzmine.parameters.impl.SimpleParameterSet;
import io.github.mzmine.util.ExitCode;
+import javafx.application.Platform;
import javafx.stage.FileChooser;
import javafx.stage.FileChooser.ExtensionFilter;
@@ -45,9 +43,10 @@ public class RawDataImportParameters extends SimpleParameterSet {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Import raw data files");
- fileChooser.getExtensionFilters()
- .addAll(new ExtensionFilter("All raw data files", "*.cdf", "*.nc", "*.mzData", "*.mzML", "*.mzXML",
- "*.xml", "*.raw", "*.csv", "*.zip", "*.gz"), //
+ fileChooser.getExtensionFilters().addAll(
+ new ExtensionFilter("All raw data files", "*.cdf", "*.nc",
+ "*.mzData", "*.mzML", "*.mzXML", "*.xml", "*.raw",
+ "*.csv", "*.zip", "*.gz"), //
new ExtensionFilter("NetCDF files", "*.cdf", "*.nc"), //
new ExtensionFilter("mzML files", "*.mzML"), //
new ExtensionFilter("mzData files", "*.mzData"), //
@@ -69,12 +68,18 @@ public class RawDataImportParameters extends SimpleParameterSet {
fileChooser.setInitialDirectory(currentDir);
}
- List<File> selectedFiles = fileChooser.showOpenMultipleDialog(null);
-
+ final FutureTask<List<File>> task = new FutureTask<>(
+ () -> fileChooser.showOpenMultipleDialog(null));
+ Platform.runLater(task);
+ try {
+ List<File> selectedFiles = task.get();
if (selectedFiles == null)
return ExitCode.CANCEL;
-
- getParameter(fileNames).setValue(selectedFiles.toArray(new File[0]));
+ getParameter(fileNames)
+ .setValue(selectedFiles.toArray(new File[0]));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
return ExitCode.OK;
