|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdsto.dfc.util.BasicPropertyEventSource
dsto.dfc.swing.persistence.AbstractDocument
public abstract class AbstractDocument
A base implementation of Document which implements the high-level bahaviour of a document without being specific to a particular persistent storage mechanism. If a model contained within this document emits either property change or change events, these are used to automatically raise the changed flag.
Field Summary | |
---|---|
protected boolean |
changed
|
Constructor Summary | |
---|---|
AbstractDocument()
|
Method Summary | |
---|---|
protected abstract void |
basicSetModel(Object newModel)
Subclasses should overrride this to actually change the model returned by getModel (). |
boolean |
checkSaveChanges()
If the document has been changed, check with the user whether the model should be saved and optionally save it. |
protected abstract Object |
createModelInstance()
Return a new model instance. |
void |
dispose()
Dispose of the object (unregister listeners, close open resources etc). |
abstract Component |
getClient()
The UI client of this document. |
protected abstract Object |
getLocation()
|
abstract Object |
getModel()
The model contained by the document. |
abstract String |
getType()
The type of document eg "Spreadsheet". |
protected void |
handleOpenError(Throwable ex)
|
protected void |
handleSaveError(Throwable ex)
|
boolean |
isChanged()
True if the model or other part of the document has changed since last saved. |
protected boolean |
isLocationSelected()
|
protected void |
modelPropertyChanged(PropertyChangeEvent e)
|
protected void |
modelStateChanged(ChangeEvent e)
|
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. |
void |
propertyChange(PropertyChangeEvent e)
PropertyChangeListener implementation: do not override this, override modelPropertyChanged instead. |
protected abstract Object |
readModel(Object location)
Read a new model object from a persistent store location. |
protected void |
registerModelListener(Object model)
|
boolean |
save()
Save the model to its original location. |
boolean |
saveAs()
Save the model to a new, user selected, location. |
protected abstract Object |
selectLocation(String mode)
Prompt the user for a location (probably in a persistent storage system) to save the model in. |
void |
setChanged(boolean newValue)
|
protected abstract void |
setLocation(Object newLocation)
The abstract location in persistent storage where the document is to be saved. |
void |
setModel(Object newModel)
Set the model contained by this document. |
void |
stateChanged(ChangeEvent e)
ChangeListener implementation: do not override this, override modelStateChanged instead. |
protected void |
unregisterModelListener(Object model)
|
protected boolean |
write(Object location)
|
protected abstract void |
writeModel(Object location,
Object model)
Write a model object to a persistent store location. |
Methods inherited from class dsto.dfc.util.BasicPropertyEventSource |
---|
addPropertyChangeListener, clone, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeSource, removePropertyChangeListener, setPropertyChangeSource |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface dsto.dfc.swing.persistence.Document |
---|
getName |
Methods inherited from interface dsto.dfc.util.PropertyEventSource |
---|
addPropertyChangeListener, removePropertyChangeListener |
Field Detail |
---|
protected boolean changed
Constructor Detail |
---|
public AbstractDocument()
Method Detail |
---|
public abstract String getType()
Document
getType
in interface Document
protected abstract Object createModelInstance()
protected abstract Object selectLocation(String mode)
readModel(java.lang.Object)
,
writeModel(java.lang.Object, java.lang.Object)
and setLocation(java.lang.Object)
.
mode
- The mode the selection is being made in: either "Open" or
"Save".
protected abstract void setLocation(Object newLocation)
protected abstract Object getLocation()
protected abstract Object readModel(Object location) throws IOException
location
- The location the persistent store to read from.
IOException
- if an error occurred while reading the model.selectLocation(java.lang.String)
protected abstract void writeModel(Object location, Object model) throws IOException
location
- The location the persistent store to write to.model
- The model to write.
IOException
- if an error occurred while writing the model.selectLocation(java.lang.String)
public abstract Component getClient()
Document
getClient
in interface Document
public abstract Object getModel()
Document
getModel
in interface Document
public void setModel(Object newModel) throws IllegalArgumentException
If the model emits either property change or change events, these are used to automatically raise the changed flag.
setModel
in interface Document
IllegalArgumentException
- if the model is not of the
correct type.protected abstract void basicSetModel(Object newModel) throws IllegalArgumentException
IllegalArgumentException
- if the model is invalid (eg not of
the correct type). If this is thrown, setModel () will revert the model
to the original instance and re-throw the exception.public boolean isChanged()
Document
isChanged
in interface Document
public void setChanged(boolean newValue)
setChanged
in interface Document
public Object newModel()
Document
newModel
in interface Document
public boolean open()
Document
open
in interface Document
Document.save()
,
Document.saveAs()
public boolean save()
Document
Document.saveAs()
.
save
in interface Document
Document.saveAs()
,
Document.open()
public boolean saveAs()
Document
saveAs
in interface Document
Document.save()
,
Document.open()
protected boolean write(Object location)
public boolean checkSaveChanges()
Document
checkSaveChanges
in interface Document
Document.save()
protected boolean isLocationSelected()
protected void handleOpenError(Throwable ex)
protected void handleSaveError(Throwable ex)
protected void unregisterModelListener(Object model)
protected void registerModelListener(Object model)
public void dispose()
Disposable
dispose
in interface Disposable
protected void modelPropertyChanged(PropertyChangeEvent e)
protected void modelStateChanged(ChangeEvent e)
public void stateChanged(ChangeEvent e)
stateChanged
in interface ChangeListener
public void propertyChange(PropertyChangeEvent e)
propertyChange
in interface PropertyChangeListener
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |