mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-11-16 19:08:49 +00:00
Save change of root directory
This commit is contained in:
parent
b4d7c60495
commit
d7d99da8f8
@ -43,14 +43,11 @@ public class RootDirectoryAction extends DefaultAction implements QuitListener
|
||||
int result = chooser.showDialog (null, "Accept");
|
||||
if (result == JFileChooser.APPROVE_OPTION)
|
||||
{
|
||||
File file = chooser.getSelectedFile ();
|
||||
if (!file.isDirectory ())
|
||||
file = file.getParentFile ();
|
||||
if (file != null)
|
||||
{
|
||||
for (RootDirectoryChangeListener listener : listeners)
|
||||
listener.rootDirectoryChanged (file);
|
||||
}
|
||||
File rootDirectoryFile = chooser.getSelectedFile ();
|
||||
if (!rootDirectoryFile.isDirectory ())
|
||||
rootDirectoryFile = rootDirectoryFile.getParentFile ();
|
||||
if (rootDirectoryFile != null)
|
||||
notifyListeners (rootDirectoryFile);
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,10 +60,8 @@ public class RootDirectoryAction extends DefaultAction implements QuitListener
|
||||
@Override
|
||||
public void quit (Preferences prefs)
|
||||
{
|
||||
if (rootFolder == null)
|
||||
prefs.put (prefsRootDirectory, "");
|
||||
else
|
||||
prefs.put (prefsRootDirectory, rootFolder.getAbsolutePath ());
|
||||
prefs.put (prefsRootDirectory,
|
||||
rootFolder == null ? "" : rootFolder.getAbsolutePath ());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -80,8 +75,13 @@ public class RootDirectoryAction extends DefaultAction implements QuitListener
|
||||
System.out.println ("No root directory");
|
||||
return;
|
||||
}
|
||||
this.rootFolder = rootDirectoryFile;
|
||||
notifyListeners (rootDirectoryFile);
|
||||
}
|
||||
|
||||
private void notifyListeners (File rootDirectoryFile)
|
||||
{
|
||||
rootFolder = rootDirectoryFile;
|
||||
for (RootDirectoryChangeListener listener : listeners)
|
||||
listener.rootDirectoryChanged (rootDirectoryFile);
|
||||
listener.rootDirectoryChanged (rootFolder);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user