Browse Source

Added a fix for when the folder we previously referenced no longer exists.

master
Drew Short 10 years ago
parent
commit
5901c36153
  1. 15
      gui/src/main/scala/com/sothr/imagetools/ui/controller/AppController.scala

15
gui/src/main/scala/com/sothr/imagetools/ui/controller/AppController.scala

@ -174,6 +174,7 @@ class AppController extends Logging {
val chooser = new DirectoryChooser()
chooser.setTitle("ImageTools Browser")
try {
val defaultDirectory = new File(currentDirectory)
chooser.setInitialDirectory(defaultDirectory)
val window = this.rootPane.getScene.getWindow
@ -184,6 +185,20 @@ class AppController extends Logging {
currentDirectory = selectedDirectory.getAbsolutePath
PropertiesService.set("app.ui.lastPath", selectedDirectory.getAbsolutePath)
this.currentDirectoryLabel.setText(selectedDirectory.getAbsolutePath)
} catch {
// fall back on the default because the directory we tried probably didn't exist
case iae: IllegalArgumentException =>
logger.error("The old directory no longer exists", iae)
chooser.setInitialDirectory(null)
val window = this.rootPane.getScene.getWindow
val selectedDirectory = chooser.showDialog(window)
info(s"Selected Directory: ${selectedDirectory.getAbsolutePath}")
selectedDirectoryLabel.setText(selectedDirectory.getAbsolutePath)
currentDirectory = selectedDirectory.getAbsolutePath
PropertiesService.set("app.ui.lastPath", selectedDirectory.getAbsolutePath)
this.currentDirectoryLabel.setText(selectedDirectory.getAbsolutePath)
}
}
@FXML

Loading…
Cancel
Save