Package diva.gui

Class DefaultStoragePolicy

  • All Implemented Interfaces:
    StoragePolicy

    public class DefaultStoragePolicy
    extends AbstractStoragePolicy
    A Default storage policy that is useful for most applications. This policy is somewhat intelligent about preventing the user from doing something stupid (like closing the document without saving).
    Version:
    $Id$
    Author:
    John Reekie, Michael Shilman
    • Constructor Detail

      • DefaultStoragePolicy

        public DefaultStoragePolicy()
    • Method Detail

      • close

        public boolean close​(Document d)
        Close the document. Forward the request to the document. Do nothing if the document is null. If the file is successfully saved and closed, then return true, otherwise return false.
      • getOpenFileChooser

        public javax.swing.JFileChooser getOpenFileChooser()
        Get the open file chooser used by this storage policy. This allows the application to set file filters on the chooser.
      • getFileChooser

        @Deprecated
        public javax.swing.JFileChooser getFileChooser()
        Deprecated.
        Use getOpenFileChooser() or getSaveFileChooser()
        Get the open file chooser used by this storage policy.
      • getSaveFileChooser

        public javax.swing.JFileChooser getSaveFileChooser()
        Get the save file chooser used by this storage policy. This allows the application to set file filters on the chooser.
      • open

        public Document open​(Application app)
        Open a new document. Open a file chooser and open the selected file using the application's document factory. Return the new document if one was created, otherwise null.
      • open

        public Document open​(java.io.File file,
                             Application app)
        Open a file and create a new document. Convert the file reference to canonical form in the process. Return the new document if one was created, otherwise null.
      • open

        public Document open​(java.net.URL url,
                             Application app)
        Open a URL and create a new document. Return the new document if one was created, otherwise null.
      • save

        public boolean save​(Document d)
        Save the document. Forward the request to the document. Do nothing if the document is null. Always return true, unless an I/O exception occurred.
      • saveAs

        public boolean saveAs​(Document d)
        Save the document to a user-specified location. Open a file chooser and forward the request to the document. Don't change the document's file object. Do nothing if the document is null. Return true if successful, otherwise false.