dsto.dfc.swing.persistence
Interface Document

All Superinterfaces:
PropertyEventSource
All Known Implementing Classes:
AbstractDocument, FileDocument

public interface Document
extends PropertyEventSource

A document is used as a wrapper around a model to provide the typical Save / Save As / Open / New / Save Changes? behaviour that a user usually expects to see with persistent documents.

Version:
$Revision$
Author:
Matthew Phillips
See Also:
AbstractDocument, FileDocument

Method Summary
 boolean checkSaveChanges()
          If the document has been changed, check with the user whether the model should be saved and optionally save it.
 Component getClient()
          The UI client of this document.
 Object getModel()
          The model contained by the document.
 String getName()
          The name of the document.
 String getType()
          The type of document eg "Spreadsheet".
 boolean isChanged()
          True if the model or other part of the document has changed since last saved.
 Object newModel()
          Create a new, empty model and set it as the document's model.
 boolean open()
          Open a new model from a persistent source such as a file.
 boolean save()
          Save the model to its original location.
 boolean saveAs()
          Save the model to a new, user selected, location.
 void setChanged(boolean newValue)
           
 void setModel(Object newModel)
          Set the model contained by the document.
 
Methods inherited from interface dsto.dfc.util.PropertyEventSource
addPropertyChangeListener, removePropertyChangeListener
 

Method Detail

getClient

Component getClient()
The UI client of this document.


setModel

void setModel(Object newModel)
              throws IllegalArgumentException
Set the model contained by the document.

Throws:
IllegalArgumentException - if the model is not of the correct type.

getModel

Object getModel()
The model contained by the document.


getName

String getName()
The name of the document.


getType

String getType()
The type of document eg "Spreadsheet".


isChanged

boolean isChanged()
True if the model or other part of the document has changed since last saved.


setChanged

void setChanged(boolean newValue)

newModel

Object newModel()
Create a new, empty model and set it as the document's model.

Returns:
The new model.

open

boolean open()
Open a new model from a persistent source such as a file.

Returns:
True if a new model was successfully opened.
See Also:
save(), saveAs()

save

boolean save()
Save the model to its original location. If the model has not been saved this is equivalent to saveAs().

Returns:
True if the model was successfully saved.
See Also:
saveAs(), open()

saveAs

boolean saveAs()
Save the model to a new, user selected, location.

Returns:
True if the model was successfully saved.
See Also:
save(), open()

checkSaveChanges

boolean checkSaveChanges()
If the document has been changed, check with the user whether the model should be saved and optionally save it.

Returns:
True if it would be safe to blow away the current model (with newModel() or open() for example) ie:
  • the document was not changed, or
  • the document was changed and the user saved it, or
  • the document was changed and the user did not want to save the changes.
See Also:
save()


Copyright © 2008 Commonwealth of Australia