Package xal.extension.application
Class AbstractApplicationAdaptor
java.lang.Object
xal.extension.application.AbstractApplicationAdaptor
- All Implemented Interfaces:
ApplicationListener
- Direct Known Subclasses:
ApplicationAdaptor
,DesktopApplicationAdaptor
AbstractApplicationAdaptor is the abstract superclass of the desktop and
frame based application adaptors. It contains hooks for handling application
events. It also provides application wide information about the application.
- Author:
- t6p
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Subclasses may override this method to provide custom handling upon completion of the application having launched.abstract String
Subclasses must implement this method to return the name of their application.void
Event indicating that the application will open any initial documents.void
Implement ApplicationListener.final boolean
Determine whether this application can open documentsvoid
customizeCommands
(Commander commander) Override this method to register custom application commands.void
documentClosed
(xal.extension.application.XalAbstractDocument document) Implement ApplicationListener.void
documentCreated
(xal.extension.application.XalAbstractDocument document) Implement ApplicationListener.abstract xal.extension.application.XalAbstractDocument
generateEmptyDocument
(String type) Generate a new empty document of the specified type.final File
Get the default document folder.final URL
Get the default document folder as a URL.getDefaultWindowReference
(String tag, Object... parameters) Get the window reference from the resource if anystatic URL[]
Get the document URLs.getResourceURL
(String resourceSpec) Get the URL to the specified resource residing within the resources directory.final Preferences
Get the node for this application's preferencesabstract String[]
Subclasses should implement this method to return the array of file suffixes identifying the files that can be read by the application.static void
setOptions
(String[] args) Define some flags for launching the application, such as pre-load a default accelerator. todo: this code needs to be reviewed to determine its value and logicvoid
setResourcesLocation
(URL resourcesLocation) Subclasses can set the location of the resources directory.void
setResourcesParentDirectory
(File resourcesParentDirectory) Convenience method to set the location of the resources directory by specifying the parent directory of resources.void
setResourcesParentDirectoryWithPath
(String resourcesParentDirectoryPath) Convenience method to set the location of the resources directory by specifying the parent directory of resources.boolean
Indicates whether the welcome dialog should be displayed at launch.boolean
Send output to console or terminal.abstract String[]
Subclasses should implement this method to return the array of file suffixes identifying the files that can be written by the application.
-
Field Details
-
WILDCARD_FILE_EXTENSION
wildcard file extension- See Also:
-
GUI_BRICKS_RESOURCE
name for the gui bricks resource which may or may not exist- See Also:
-
docURLs
The URLs to open existing document(s) in the command-line.
-
-
Constructor Details
-
AbstractApplicationAdaptor
protected AbstractApplicationAdaptor()Constructor
-
-
Method Details
-
getDefaultDocumentFolder
Get the default document folder.- Returns:
- the default folder for documents or null if none has been set.
-
getDefaultDocumentFolderURL
Get the default document folder as a URL.- Returns:
- the default folder for documents as a URL or null if none has been set.
-
readableDocumentTypes
Subclasses should implement this method to return the array of file suffixes identifying the files that can be read by the application.- Returns:
- An array of file suffixes corresponding to readable files
-
writableDocumentTypes
Subclasses should implement this method to return the array of file suffixes identifying the files that can be written by the application.- Returns:
- An array of file suffixes corresponding to writable files
-
canOpenDocuments
public final boolean canOpenDocuments()Determine whether this application can open documents -
showsWelcomeDialogAtLaunch
public boolean showsWelcomeDialogAtLaunch()Indicates whether the welcome dialog should be displayed at launch. By default, this returns true if the application can open documents. -
generateEmptyDocument
Generate a new empty document of the specified type.- Parameters:
type
- the type of document to create.- Returns:
- an instance of the custom subclass of XalAbstractDocument
-
applicationName
Subclasses must implement this method to return the name of their application.- Returns:
- The name of the application
-
getUserPreferencesNode
Get the node for this application's preferences -
usesConsole
public boolean usesConsole()Send output to console or terminal. Identifies whether the application sends standard output and standard error to the application's console or whether it should simply go to the terminal from which the application was launched. The default is to return true thus indicating that the console should be used. If environment variable XAL_USE_CONSOLE is set to false, then output is sent to terminal instead. Individual applications may implement a different solution.- Returns:
- Whether the application's console should capture standard output and error
-
customizeCommands
Override this method to register custom application commands.- Parameters:
commander
- The commander with which to register commands.- See Also:
-
setOptions
Define some flags for launching the application, such as pre-load a default accelerator. todo: this code needs to be reviewed to determine its value and logic -
getDocURLs
Get the document URLs.- Returns:
- document URLs
-
getDefaultWindowReference
Get the window reference from the resource if any -
applicationWillOpenInitialDocuments
public void applicationWillOpenInitialDocuments()Event indicating that the application will open any initial documents. These documents may include a new empty document if appropriate or any documents passed at the command line. Subclasses may override this method to handle this event if needed.- Specified by:
applicationWillOpenInitialDocuments
in interfaceApplicationListener
-
applicationFinishedLaunching
public void applicationFinishedLaunching()Subclasses may override this method to provide custom handling upon completion of the application having launched. The default implementation prints a simple info to logger -
documentClosed
public void documentClosed(xal.extension.application.XalAbstractDocument document) Implement ApplicationListener. Subclasses may implement this method to handle a document closed event at the application level. The default implementation does nothing.- Specified by:
documentClosed
in interfaceApplicationListener
- Parameters:
document
- The document that has closed.
-
documentCreated
public void documentCreated(xal.extension.application.XalAbstractDocument document) Implement ApplicationListener. Subclasses may implement this method to handle a document created event at the application level. The default implementation does nothing.- Specified by:
documentCreated
in interfaceApplicationListener
- Parameters:
document
- The document that has been created.
-
applicationWillQuit
public void applicationWillQuit()Implement ApplicationListener. Subclasses may implement this method to handle an "application will quit" event at the application level. The default implementation does nothing.- Specified by:
applicationWillQuit
in interfaceApplicationListener
-
setResourcesParentDirectory
Convenience method to set the location of the resources directory by specifying the parent directory of resources. The resources directory is assumed to be named "resources". This is really used for script based applications that don't reside in a jar file.- Parameters:
resourcesParentDirectory
- normal file system directory specifying the location of the parent directory of the resources
-
setResourcesParentDirectoryWithPath
Convenience method to set the location of the resources directory by specifying the parent directory of resources. The resources directory is assumed to be named "resources". This is really used for script based applications that don't reside in a jar file.- Parameters:
resourcesParentDirectoryPath
- full file system directory path specifying the location of the parent directory of the resources
-
setResourcesLocation
Subclasses can set the location of the resources directory. Setting it to null will use the default resource manager. -
getResourceURL
Get the URL to the specified resource residing within the resources directory.- Parameters:
resourceSpec
- specification of the resource relative to the resources URL- Returns:
- the full URL to the specified resource
-