Skip to content
Snippets Groups Projects
Commit 8de2b80d authored by Lange, Dr. Herbert's avatar Lange, Dr. Herbert
Browse files

reuse previous selection for file/path selection

parent 1044effe
No related branches found
No related tags found
No related merge requests found
Pipeline #12305 passed
...@@ -38,6 +38,10 @@ public class GUI { ...@@ -38,6 +38,10 @@ public class GUI {
corpusButton.addActionListener(actionEvent -> { corpusButton.addActionListener(actionEvent -> {
JFileChooser chooser = new JFileChooser(); JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
// Use previous path if there is one
if (!corpusPath.getText().isBlank()) {
chooser.setCurrentDirectory(new File(corpusPath.getText()));
}
int result = chooser.showOpenDialog(corpusButton); int result = chooser.showOpenDialog(corpusButton);
if (result == JFileChooser.APPROVE_OPTION) if (result == JFileChooser.APPROVE_OPTION)
corpusPath.setText(chooser.getSelectedFile().toString()); corpusPath.setText(chooser.getSelectedFile().toString());
...@@ -53,6 +57,10 @@ public class GUI { ...@@ -53,6 +57,10 @@ public class GUI {
JFileChooser chooser = new JFileChooser(); JFileChooser chooser = new JFileChooser();
chooser.setFileFilter(new FileNameExtensionFilter( chooser.setFileFilter(new FileNameExtensionFilter(
"YAML configurations", "yaml", "yml")); "YAML configurations", "yaml", "yml"));
// Use previous path if there is one
if (!configPath.getText().isBlank()) {
chooser.setCurrentDirectory(new File(configPath.getText()).getParentFile());
}
int result = chooser.showOpenDialog(configButton); int result = chooser.showOpenDialog(configButton);
if (result == JFileChooser.APPROVE_OPTION) if (result == JFileChooser.APPROVE_OPTION)
configPath.setText(chooser.getSelectedFile().toString()); configPath.setText(chooser.getSelectedFile().toString());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment