1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-21 15:54:39 +01:00

Revert "Replaced JFileChooser with FileDialog in 'Add .zip library'"

This reverts commit 7cb14400068529bbb917241880a92ab918a4d7bd.
This commit is contained in:
Cristian Maglie 2020-02-10 09:47:15 +01:00
parent 33ff49566c
commit 678420cd47

View File

@ -2340,27 +2340,21 @@ public class Base {
}
public void handleAddLibrary() {
// get the frontmost window frame for placing file dialog
FileDialog fd = new FileDialog(activeEditor, tr("Select a zip file or a folder containing the library you'd like to add"), FileDialog.LOAD);
File home = new File(System.getProperty("user.home"));
if (home.isDirectory()) {
fd.setDirectory(home.getAbsolutePath());
JFileChooser fileChooser = new JFileChooser(System.getProperty("user.home"));
fileChooser.setDialogTitle(tr("Select a zip file or a folder containing the library you'd like to add"));
fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
fileChooser.setFileFilter(new FileNameExtensionFilter(tr("ZIP files or folders"), "zip"));
Dimension preferredSize = fileChooser.getPreferredSize();
fileChooser.setPreferredSize(new Dimension(preferredSize.width + 200, preferredSize.height + 200));
int returnVal = fileChooser.showOpenDialog(activeEditor);
if (returnVal != JFileChooser.APPROVE_OPTION) {
return;
}
if (OSUtils.isWindows()) {
// Workaround: AWT FileDialog doesn't not support native file filters on Windows...
// https://stackoverflow.com/questions/12558413/how-to-filter-file-type-in-filedialog
fd.setFile("*.zip");
}
fd.setFilenameFilter((dir, name) -> name.toLowerCase().endsWith(".zip"));
fd.setVisible(true);
String directory = fd.getDirectory();
String filename = fd.getFile();
// User canceled selection
if (filename == null) return;
File sourceFile = new File(directory, filename);
File sourceFile = fileChooser.getSelectedFile();
File tmpFolder = null;
try {