forked from JabRef/jabref
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NewFileDialogs will be renamed when the work is done Atm I want to keep it parallel during
- Loading branch information
1 parent
71eca69
commit e1eb25c
Showing
4 changed files
with
108 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package net.sf.jabref.gui; | ||
|
||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import javax.swing.JFileChooser; | ||
import javax.swing.JFrame; | ||
|
||
import net.sf.jabref.Globals; | ||
import net.sf.jabref.JabRefPreferences; | ||
|
||
/** | ||
* WIP: Will replaced the FileDialogs class | ||
* | ||
* | ||
*/ | ||
public class NewFileDialogs { | ||
|
||
public static List<String> getMultipleFiles(JFrame owner, String extension, boolean workingDir, | ||
boolean updateWorkingDirSetting) { | ||
|
||
Path dir = Paths.get("."); | ||
if (workingDir) { | ||
dir = Paths.get(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)); | ||
} | ||
return getMultipleFiles(owner, dir, extension, updateWorkingDirSetting); | ||
|
||
} | ||
|
||
public static List<String> getMultipleFiles(JFrame owner, Path directory, String extension, | ||
boolean updateWorkingDirSetting) { | ||
|
||
OpenFileFilter off = null; | ||
if (extension == null) { | ||
off = new OpenFileFilter(); | ||
} else if (!extension.isEmpty()) { | ||
off = new OpenFileFilter(extension); | ||
} | ||
|
||
JFileChooser chooser = new JFileChooser(directory.toFile()); | ||
chooser.setMultiSelectionEnabled(true); | ||
chooser.setFileFilter(off); | ||
if (chooser.showOpenDialog(owner) == JFileChooser.APPROVE_OPTION) { | ||
|
||
if (updateWorkingDirSetting) { | ||
updateWorkingDirectorySetting(chooser.getSelectedFile().toString()); | ||
} | ||
return Arrays.stream(chooser.getSelectedFiles()).map(f -> f.toString()).collect(Collectors.toList()); | ||
} | ||
|
||
return Collections.emptyList(); | ||
|
||
} | ||
|
||
private static void updateWorkingDirectorySetting(String dir) { | ||
Globals.prefs.put(JabRefPreferences.WORKING_DIRECTORY, dir); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters