public abstract class Application
extends java.lang.Object
getApp()
provides access to that instance. Every application has one custom
application adaptor. The adaptor acts as a delegate for handling events
specific to the custom application. The Application, however, handles events
common to all multi-document applications.Modifier and Type | Field and Description |
---|---|
protected AbstractApplicationAdaptor |
_applicationAdaptor |
protected Commander |
_commander |
protected ApplicationListener |
_noticeProxy |
protected java.util.List<xal.extension.application.XalAbstractDocument> |
_openDocuments |
static int |
NO_OPTION |
static int |
YES_OPTION |
Modifier | Constructor and Description |
---|---|
protected |
Application(AbstractApplicationAdaptor adaptor)
Application constructor.
|
protected |
Application(AbstractApplicationAdaptor adaptor,
java.net.URL[] urls)
Application constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addApplicationListener(ApplicationListener listener)
Add the listener as a listener of Application events.
|
protected boolean |
canOpenDocuments()
Determine whether this application can open documents
|
protected void |
cascadeWindowsAbout(xal.extension.application.XalAbstractDocument targetDocument)
Handle the "Cascade Windows" action by cascading all document windows about the target document.
|
protected void |
closeAllDocuments()
Handle the "Close All" action by closing all open documents and opening a new empty document.
|
protected void |
closeDocument(xal.extension.application.XalAbstractDocument document)
Handle the "Close" action by closing the specified document.
|
static void |
displayApplicationError(java.lang.String title,
java.lang.String prefix,
java.lang.Exception exception)
Display an error dialog box with information about the exception.
|
static int |
displayConfirmDialog(java.lang.String title,
java.lang.String message)
Display a confirmation dialog with a title and message
|
static void |
displayError(java.lang.Exception exception)
Display an error dialog box with information about the exception.
|
static void |
displayError(java.lang.String title,
java.lang.String message)
Display an error dialog box.
|
static void |
displayError(java.lang.String title,
java.lang.String prefix,
java.lang.Exception exception)
Display an error dialog box with information about the exception.
|
static void |
displayWarning(java.lang.Exception exception)
Display a warning dialog box with information about the exception.
|
static void |
displayWarning(java.lang.String title,
java.lang.String message)
Display a warning dialog box.
|
static void |
displayWarning(java.lang.String title,
java.lang.String prefix,
java.lang.Exception exception)
Display a warning dialog box with information about the exception.
|
static java.awt.Window |
getActiveWindow()
Get the active window which is in focus for this application.
|
static AbstractApplicationAdaptor |
getAdaptor()
Convenience method for getting the custom application adaptor.
|
static Application |
getApp()
Get the application instance.
|
AbstractApplicationAdaptor |
getApplicationAdaptor()
Get the custom application adaptor.
|
Commander |
getCommander()
Get the application commander that manages commands for the entire application.
|
java.io.File |
getDefaultDocumentFolder()
Get the default document folder.
|
java.net.URL |
getDefaultDocumentFolderURL()
Get the default document folder as a URL.
|
java.util.List<xal.extension.application.XalAbstractDocument> |
getDocuments()
Get the unmodifiable list of all open documents.
|
<DocumentType extends xal.extension.application.XalAbstractDocument> |
getDocumentsCopy()
Get a copy of the list of all open documents.
|
java.util.Date |
getLaunchTime()
Get the launch time which is the time at which the Application instance was instantiated.
|
protected java.awt.Point |
getNextDocumentOpenLocation()
get the location of the next document to open
|
javax.swing.JFileChooser |
getOpenFileChooser()
Get the file chooser with which the user interacts when opening a document.
|
javax.swing.JFileChooser |
getSaveFileChooser()
Get the file chooser with which the user interacts when saving a document.
|
protected void |
hideAllWindows()
Handle the "Hide All" action by hiding all main windows corresponding
to the open documents.
|
static void |
launch(AbstractApplicationAdaptor adaptor)
Handle the launching of the application by creating the application instance
and performing application initialization.
|
static void |
launch(AbstractApplicationAdaptor adaptor,
java.net.URL[] urls)
Handle the launching of the application by creating the application instance
and performing application initialization.
|
protected Commander |
makeCommander()
Make an application commander
|
protected void |
makeFileChoosers()
Create a file chooser for opening and saving documents.
|
protected abstract void |
newDocument()
Create and open a new empty document.
|
protected abstract void |
newDocument(java.lang.String type)
Create and open a new empty document of the specified type.
|
protected void |
newDocumentFromTemplate()
Create a new document based on a user selected document
|
protected void |
openDocument()
Handle the "Open" action by opening a new document.
|
void |
openDocument(java.net.URL url)
Support method for opening a document with the specified URL.
|
protected void |
openDocumentVersion(xal.extension.application.XalAbstractDocument document)
present the user with a dialog box to open a version of the specified document
|
protected void |
openFile(java.io.File file)
Support method for opening a new document given a file.
|
protected void |
openFiles(java.io.File[] files)
Support method for opening an array of files.
|
protected void |
openURL(java.lang.String urlSpec)
Support method for opening a new document with the URL specification
|
void |
produceDocument(xal.extension.application.XalAbstractDocument document)
Add a new document to this application and show it
|
abstract void |
produceDocument(xal.extension.application.XalAbstractDocument document,
boolean makeVisible)
Add a new document to this application and if makeVisible is true, show it
|
void |
quit()
Handle the "Quit" action by quitting the application.
|
protected void |
registerApplicationStatusService()
Register the application status service so clients on the network can query the status of this application instance.
|
protected void |
registerEvents()
Register the instance as a provider for ApplictionListener events.
|
void |
removeApplicationListener(ApplicationListener listener)
Remove the listener from listening to Application events.
|
protected void |
revertToSaved(xal.extension.application.XalAbstractDocument document)
Handle the "Revert To Saved" action by reverting the specified document to that of its source file.
|
protected void |
saveAllDocuments()
Handle the "Save All" action by saving all open documents.
|
protected void |
saveAsDocument(xal.extension.application.XalAbstractDocument document)
Handle the "Save As" action by saving the specified document to the location chosen by the user.
|
protected void |
saveDocument(xal.extension.application.XalAbstractDocument document)
Handle the "Save" action by saving the specified document.
|
protected void |
saveDocumentToFile(xal.extension.application.XalAbstractDocument document,
java.io.File file)
Support method for saving a document to a file.
|
protected void |
setNextDocumentOpenLocation(java.awt.Point location)
Set the next document open location
|
void |
setOpenFileChooser(javax.swing.JFileChooser fileChooser)
Set the file chooser with which the user will interact when opening a document.
|
void |
setSaveFileChooser(javax.swing.JFileChooser fileChooser)
Set the file chooser with which the user will interact when saving a document.
|
protected abstract void |
setup(java.net.URL[] urls)
Initialize the Application and open the documents specified by the URL array.
|
protected void |
setupConsole()
Setup the console to capture standard output and standard error
|
static void |
showAboutBox()
show the about box
|
protected void |
showAllWindows()
Handle the "Show All" action by showing all main windows corresponding
to the open documents.
|
protected int |
showOpenFileChooser()
Show the save file chooser.
|
protected int |
showSaveFileChooser(xal.extension.application.XalAbstractDocument document)
Show the save file chooser.
|
protected boolean |
showsWelcomeDialogAtLaunch()
Indicates whether the welcome dialog should be displayed at launch
|
protected void |
showWelcomeDialog()
show the welcome dialog which offers to open a new document, template or existing document.
|
protected void |
updateNextDocumentOpenLocation()
Set the location of the next document to open based on the location of the active application document window
|
public static final int YES_OPTION
public static final int NO_OPTION
protected AbstractApplicationAdaptor _applicationAdaptor
protected java.util.List<xal.extension.application.XalAbstractDocument> _openDocuments
protected Commander _commander
protected ApplicationListener _noticeProxy
protected Application(AbstractApplicationAdaptor adaptor)
adaptor
- The application adaptor used for customization.protected Application(AbstractApplicationAdaptor adaptor, java.net.URL[] urls)
adaptor
- The application adaptor used for customization.urls
- An array of document URLs to open upon startup.public java.util.Date getLaunchTime()
public Commander getCommander()
protected boolean canOpenDocuments()
protected boolean showsWelcomeDialogAtLaunch()
protected void showWelcomeDialog()
protected abstract void setup(java.net.URL[] urls)
urls
- An array of document URLs to open.protected Commander makeCommander()
protected final void registerApplicationStatusService()
protected void setupConsole()
public javax.swing.JFileChooser getSaveFileChooser()
public void setSaveFileChooser(javax.swing.JFileChooser fileChooser)
fileChooser
- The file chooser with which the user will interact when saving a document.public javax.swing.JFileChooser getOpenFileChooser()
public void setOpenFileChooser(javax.swing.JFileChooser fileChooser)
fileChooser
- The file chooser with which the user will interact when opening a document.protected void makeFileChoosers()
protected java.awt.Point getNextDocumentOpenLocation()
protected void setNextDocumentOpenLocation(java.awt.Point location)
protected void updateNextDocumentOpenLocation()
protected void registerEvents()
public void addApplicationListener(ApplicationListener listener)
listener
- Object to register as a listener of application events.public void removeApplicationListener(ApplicationListener listener)
listener
- Object to un-register as a listener of application events.public java.util.List<xal.extension.application.XalAbstractDocument> getDocuments()
public <DocumentType extends xal.extension.application.XalAbstractDocument> java.util.List<DocumentType> getDocumentsCopy()
public AbstractApplicationAdaptor getApplicationAdaptor()
getAdaptor()
protected abstract void newDocument()
protected abstract void newDocument(java.lang.String type)
type
- the type of document to create.protected void newDocumentFromTemplate()
protected int showOpenFileChooser()
protected void openDocument()
protected void openURL(java.lang.String urlSpec)
urlSpec
- The URL specification of the file to open.protected void openFile(java.io.File file)
file
- The file to open.openFiles(java.io.File[])
protected void openFiles(java.io.File[] files)
files
- The files to open.openDocument()
public void openDocument(java.net.URL url)
url
- The URL of the file to open.openURL(java.lang.String)
,
openFile(java.io.File)
protected void closeDocument(xal.extension.application.XalAbstractDocument document)
document
- The document to close.protected void closeAllDocuments()
protected int showSaveFileChooser(xal.extension.application.XalAbstractDocument document)
protected void saveDocument(xal.extension.application.XalAbstractDocument document)
document
- The document to save.protected void openDocumentVersion(xal.extension.application.XalAbstractDocument document)
protected void saveAsDocument(xal.extension.application.XalAbstractDocument document)
document
- The document to save.protected void saveAllDocuments()
protected void saveDocumentToFile(xal.extension.application.XalAbstractDocument document, java.io.File file)
document
- The document to save.file
- The file to which the document will be saved.protected void revertToSaved(xal.extension.application.XalAbstractDocument document)
document
- The document to revert.public void quit()
protected void cascadeWindowsAbout(xal.extension.application.XalAbstractDocument targetDocument)
targetDocument
- The document about whose window all document windows should cascadeprotected void showAllWindows()
protected void hideAllWindows()
public static void showAboutBox()
public java.io.File getDefaultDocumentFolder()
public java.net.URL getDefaultDocumentFolderURL()
public static void launch(AbstractApplicationAdaptor adaptor)
adaptor
- The custom application adaptor.public static void launch(AbstractApplicationAdaptor adaptor, java.net.URL[] urls)
adaptor
- The custom application adaptor.urls
- The URLs of documents to open upon launching the applicationpublic static AbstractApplicationAdaptor getAdaptor()
getApplicationAdaptor()
public static Application getApp()
public static java.awt.Window getActiveWindow()
public void produceDocument(xal.extension.application.XalAbstractDocument document)
document
- the document to producepublic abstract void produceDocument(xal.extension.application.XalAbstractDocument document, boolean makeVisible)
document
- the document to producemakeVisible
- make the document visiblepublic static int displayConfirmDialog(java.lang.String title, java.lang.String message)
title
- The title of the dialogmessage
- The message to displaypublic static void displayWarning(java.lang.Exception exception)
exception
- The exception about which the warning dialog is displayed.public static 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 static 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 static 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 static void displayError(java.lang.Exception exception)
exception
- The exception about which the warning dialog is displayed.public static 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 static void displayApplicationError(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.