Swing Application Framework session store

1.8k Views Asked by At

I have been using the Swing Application Framework, and very pleased with its sessions state storage. I was wondering if it's possible to delete (clean up) the persisted states.

  • of All dialog forms. or
  • of specific dialog forms.

If not, has anyone found a clean way to achieve this (stored files aren't saved in the same location depending on the OS etc..).

Thanks

2

There are 2 best solutions below

1
On BEST ANSWER

you can delete the corresponding file/s (forgot the exact details about the naming) via the LocalStorage, here's a code snippet I use (with bsaf, but didn't change much, afair)

/**
 * Deletes the session state by deleting the file. Useful during development
 * when restoring to old state is not always the desired behaviour.
 * Pending: this is incomplete, deletes the mainframe state only.
 */
protected void deleteSessionState() {
    ApplicationContext context = getContext();
    try {
        context.getLocalStorage().deleteFile("mainFrame.session.xml");
    } catch (...) {
    }
}
1
On
        File directory = context.getLocalStorage().getDirectory();
        directory = directory.getCanonicalFile();
        Files.deleteDirectoryContents(directory);

Files is the google io lib.