public abstract class XalDocument
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
XalWindow |
mainWindow |
protected MessageCenter |
MESSAGE_CENTER
Local message center
|
static int |
NO_OPTION |
protected java.net.URL |
source
The persistent storage URL for the document
|
static java.lang.String |
WILDCARD_FILE_EXTENSION
wildcard file extension
|
static int |
YES_OPTION |
Constructor and Description |
---|
XalDocument()
Constructor for new documents
|
Modifier and Type | Method and Description |
---|---|
void |
addXalDocumentListener(XalDocumentListener listener)
Add the listener for events from this document.
|
boolean |
closeDocument()
This method is a request to close a document.
|
void |
customizeCommands(Commander commander)
Override this method to register custom document commands if any.
|
int |
displayConfirmDialog(java.lang.String title,
java.lang.String message)
Display a confirmation dialog with a title and message
|
void |
displayError(java.lang.Exception exception)
Display an error dialog box with information about the exception and
provide an audible alert.
|
void |
displayError(java.lang.String title,
java.lang.String message)
Display an error dialog box and provide an audible alert.
|
void |
displayError(java.lang.String title,
java.lang.String prefix,
java.lang.Exception exception)
Display an error dialog box with information about the exception and
provide an audible alert.
|
void |
displayWarning(java.lang.Exception exception)
Display a warning dialog box with information about the exception and provide
an audible alert.
|
void |
displayWarning(java.lang.String title,
java.lang.String message)
Display a warning dialog box and provide an audible alert.
|
void |
displayWarning(java.lang.String title,
java.lang.String prefix,
java.lang.Exception exception)
Display a warning dialog box with information about the exception and provide
an audible alert.
|
void |
freeCustomResources()
Dispose of custom document resources.
|
void |
freeResources()
Free document resources.
|
void |
generateDocumentTitle()
Generate and set the title for this document.
|
java.lang.String |
getCustomMenuDefinitionResource()
Subclasses should override this method if this document should use a menu definition
other than the default specified in application adaptor.
|
java.io.File |
getDefaultFolder()
Get the default document folder.
|
java.net.URL |
getDefaultFolderURL()
Get the default document folder as a URL.
|
static WindowReference |
getDefaultWindowReference(java.lang.String tag,
java.lang.Object... parameters)
Get the window reference from the resource if any
|
java.lang.String |
getDisplayFilePath()
By default the file path to display for this document is set to the file path of the
document or the default empty document file path if the document does not yet have
a file store.
|
XalDocumentView |
getDocumentView()
Implement the method for XalAbstractDocument.
|
java.lang.String |
getEmptyDocumentPath()
Get the default file path to use for empty documents
|
java.lang.String |
getFileNameForSaving()
Get the base file name to use when saving a new file.
|
XalWindow |
getMainWindow()
Get the main window for this document.
|
java.lang.String |
getNewDocumentName(java.lang.String baseName)
Get the default file path to use for empty documents
|
java.lang.String |
getNewFileName()
Get the file name (including extension but without path) for a new file.
|
java.lang.String |
getNewFileNamePrefix()
Get the prefix for a new file (precedes timestamp) defaulting to the application name.
|
int |
getNumberOfPages()
Implement the Pageable interface.
|
java.awt.print.PageFormat |
getPageFormat(int pageIndex)
Implement the Pageable interface.
|
java.awt.print.Printable |
getPrintable(int pageIndex)
Implement the Pageable interface.
|
java.net.URL |
getSource()
Get the URL of the persistent storage for this document.
|
java.lang.String |
getTitle()
Get the document title.
|
void |
handleDataWrittenTo(DataListener dataRoot,
java.net.URL url)
Subclasses may override this empty method to implement custom code called by writeDataTo() after data has been successfully written to the specified URL.
|
boolean |
hasChanges()
Indicates if there are changes that need saving.
|
void |
hideDocument()
Hide this document.
|
boolean |
isEmpty()
Check if the document is empty.
|
abstract void |
makeMainWindow()
Subclasses must implement this method to make their custom main window.
|
void |
registerEvents()
Register this document as a source of DocumentListener events.
|
void |
removeXalDocumentListener(XalDocumentListener listener)
Remove the listener from event from this document.
|
void |
saveDocument()
Save this document to its persistent storage source.
|
abstract void |
saveDocumentAs(java.net.URL url)
Subclasses need to implement this method for saving the document to a URL.
|
void |
setHasChanges(boolean changeStatus)
Set the whether this document has changes.
|
void |
setSource(java.net.URL url)
Set the URL of the persistent storage for this document.
|
void |
setTitle(java.lang.String newTitle)
Set the document title.
|
void |
showDocument()
Make this document's window visible.
|
boolean |
warnUserOfUnsavedChangesWhenClosing()
Determine whether the user should be warned when closing a document with unsaved changes.
|
void |
willClose()
Called when the document will be closed.
|
void |
windowOpened()
Hook indicating that the window was opened.
|
void |
windowWillOpen()
Hook indicating that the window will be opened.
|
java.lang.String[] |
writableDocumentTypes()
Subclasses should implement this method to return the array of file
suffixes identifying the files that can be written by the document.
|
void |
writeDataTo(DataListener dataRoot,
java.net.URL url)
Convenience method typically called in saveDocumentAs() to save a document rooted in a data listener source.
|
public static final java.lang.String WILDCARD_FILE_EXTENSION
public static final int YES_OPTION
public static final int NO_OPTION
public XalWindow mainWindow
protected MessageCenter MESSAGE_CENTER
protected java.net.URL source
public void registerEvents()
public void addXalDocumentListener(XalDocumentListener listener)
public void removeXalDocumentListener(XalDocumentListener listener)
public static WindowReference getDefaultWindowReference(java.lang.String tag, java.lang.Object... parameters)
public void setTitle(java.lang.String newTitle)
newTitle
- The new title for this document.public void setHasChanges(boolean changeStatus)
changeStatus
- Status to set whether this document has changes that need saving.public boolean closeDocument()
public final void freeResources()
public XalWindow getMainWindow()
public XalDocumentView getDocumentView()
public java.lang.String[] writableDocumentTypes()
public abstract void makeMainWindow()
public void customizeCommands(Commander commander)
commander
- The commander that manages commands.Commander.registerAction(Action)
public java.lang.String getCustomMenuDefinitionResource()
public java.lang.String getTitle()
public java.net.URL getSource()
public java.io.File getDefaultFolder()
public java.net.URL getDefaultFolderURL()
public void setSource(java.net.URL url)
url
- The URL of the persistent storage to set for this document.public boolean isEmpty()
public void generateDocumentTitle()
public java.lang.String getDisplayFilePath()
public java.lang.String getFileNameForSaving()
public java.lang.String getNewFileNamePrefix()
public java.lang.String getNewFileName()
public java.lang.String getNewDocumentName(java.lang.String baseName)
baseName
- the base name to use for an empty documentpublic java.lang.String getEmptyDocumentPath()
public boolean hasChanges()
public abstract void saveDocumentAs(java.net.URL url)
url
- The URL to which this document should be saved.public void saveDocument()
public void writeDataTo(DataListener dataRoot, java.net.URL url)
dataRoot
- DataListener root of the document to saveurl
- The URL to which the document should be saved.public void handleDataWrittenTo(DataListener dataRoot, java.net.URL url)
dataRoot
- DataListener root of the document to saveurl
- The URL to which the document should be saved.public boolean warnUserOfUnsavedChangesWhenClosing()
public void freeCustomResources()
public void willClose()
public void windowWillOpen()
public void windowOpened()
public void showDocument()
public void hideDocument()
public int displayConfirmDialog(java.lang.String title, java.lang.String message)
title
- The title of the dialogmessage
- The message to displaypublic void displayWarning(java.lang.String title, java.lang.String message)
title
- Title of the warning dialog box.message
- The warning message to appear in the warning dialog box.public void displayWarning(java.lang.Exception exception)
exception
- The exception about which the warning dialog is displayed.public void displayWarning(java.lang.String title, java.lang.String prefix, java.lang.Exception exception)
title
- Title of the warning dialog box.prefix
- Text that should appear in the dialog box before the exception messasge.exception
- The exception about which the warning dialog is displayed.public void displayError(java.lang.String title, java.lang.String message)
title
- Title of the warning dialog box.message
- The warning message to appear in the warning dialog box.public void displayError(java.lang.Exception exception)
exception
- The exception about which the warning dialog is displayed.public void displayError(java.lang.String title, java.lang.String prefix, java.lang.Exception exception)
title
- Title of the warning dialog box.prefix
- Text that should appear in the dialog box before the exception messasge.exception
- The exception about which the warning dialog is displayed.public int getNumberOfPages()
getNumberOfPages
in interface java.awt.print.Pageable
public java.awt.print.PageFormat getPageFormat(int pageIndex) throws java.lang.IndexOutOfBoundsException
getPageFormat
in interface java.awt.print.Pageable
pageIndex
- The page number corresponding to the page format to returnjava.lang.IndexOutOfBoundsException
- when the page index is out of rangePrintManager.getPageFormat()
public java.awt.print.Printable getPrintable(int pageIndex) throws java.lang.IndexOutOfBoundsException
getPrintable
in interface java.awt.print.Pageable
pageIndex
- The page to printjava.lang.IndexOutOfBoundsException
- when the page index is out of range