diva.gui
Class DefaultStoragePolicy

java.lang.Object
  extended by diva.gui.AbstractStoragePolicy
      extended by diva.gui.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: DefaultStoragePolicy.java 38798 2005-07-08 20:00:01Z cxh $
Author:
John Reekie, Michael Shilman

Field Summary
private  javax.swing.JFileChooser _openFileChooser
          The file chooser that is used to open files.
private  javax.swing.JFileChooser _saveFileChooser
          The file chooser that is used to save files.
 
Constructor Summary
DefaultStoragePolicy()
           
 
Method Summary
 boolean close(Document d)
          Close the document.
 javax.swing.JFileChooser getFileChooser()
          Deprecated. Use getOpenFileChooser() or getSaveFileChooser()
 javax.swing.JFileChooser getOpenFileChooser()
          Get the open file chooser used by this storage policy.
 javax.swing.JFileChooser getSaveFileChooser()
          Get the save file chooser used by this storage policy.
 Document open(Application app)
          Open a new document.
 Document open(java.io.File file, Application app)
          Open a file and create a new document.
 Document open(java.net.URL url, Application app)
          Open a URL and create a new document.
 boolean save(Document d)
          Save the document.
 boolean saveAs(Document d)
          Save the document to a user-specified location.
 
Methods inherited from class diva.gui.AbstractStoragePolicy
getDirectory, setDirectory, setDirectory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_openFileChooser

private javax.swing.JFileChooser _openFileChooser
The file chooser that is used to open files. This can be accessed with the getOpenFileChooser() methods so that applications can add/manipulate file filters.


_saveFileChooser

private javax.swing.JFileChooser _saveFileChooser
The file chooser that is used to save files. This can be accessed with the getSaveFileChooser() methods so that applications can add/manipulate file filters.

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

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.