Andrew Liles - 2015-10-11

Here's my initial idea of how this feature could be implemented - I've only skimmed the code, so lots could be wrong here. David, please provide your feedback before I sart.

  1. Create a FileChangeNotification interface, one method notifyFileChange(File)
  2. Create a FileWatcher class (could use a library, but avoiding that, roll own)
    Class allows the setting or unsetting of a single file to monitor.
    Class would support the subscription of N listeners
    On init a daemon thread is created that looks for the sole registered file every 5 seconds. On first run, the timestamp of the file is recorded. If on the 2nd+ iteration the file has a more recent time, then subscribers are notified.

  3. In PasswordSafeJFace constructor, setup FileWatcher, set self as a listener

  4. In PasswordSafeJFace.openFile(String, StringBuilder, boolean)
    register file with FileWatcher. Consider how failed open should work
  5. In PasswordSafeJFace.saveFile & saveFileAs de-register file first, then re-register to prevent notifications from self
  6. In PasswordSafeJFace.tidyUpOnExit shutdown FileWatcher
  7. In PasswordSafeJFace.notifyFileChange
    markFileChange
    if(!isLocked) {
    show file changed warning dialog box (on correct thread)
    }
  8. In clearView()
    dispose of changeFileDialog if necessary
  9. In UnlockDbAction
    if(fileChanged)
    show file changed warning dialog box

  10. File Changed Warning dialog box needs further thought (aid of Sequence Diagram) to cater for all the scenarios..., e.g. remote change with dirty local change.