gov.sns.application
Class ApplicationAdaptor

java.lang.Object
  |
  +--gov.sns.application.ApplicationAdaptor
All Implemented Interfaces:
ApplicationListener
Direct Known Subclasses:
Demo, Main, Showcase, Showcase

public abstract class ApplicationAdaptor
extends java.lang.Object
implements ApplicationListener

ApplicationAdaptor is the abstract superclass of the custom applicaton adaptors each of which acts as a delegate for its corresponding application. It contains hooks for handling application events. It also provides application wide information about the application.


Field Summary
static java.net.URL[] docURLs
          The URLs to open existing document(s) in the command-line.
 
Constructor Summary
ApplicationAdaptor()
           
 
Method Summary
 void applicationFinishedLaunching()
          Subclasses may override this method to provide custom handling upon completion of the application having launched.
abstract  java.lang.String applicationName()
          Subclasses must implement this method to return the name of their application.
 void applicationWillQuit()
          Implement ApplicationListener.
protected  void customizeCommands(Commander commander)
          Override this method to register custom application commands.
 void documentClosed(XalDocument document)
          Implement ApplicationListener.
 void documentCreated(XalDocument document)
          Implement ApplicationListener.
 void editPreferences(XalDocument document)
          Override this method to show your application's preference panel.
 java.lang.String getApplicationHelpPath()
          Subclasses should override this method if the application Help file is in a location other than the default one.
 java.lang.String getApplicationInfoPath()
          Subclasses should override this method if the application information properties (displayed in the "About" box) file is in a location other than the default one.
static java.net.URL[] getDocURLs()
           
 java.lang.String getMenuDefinitionPath()
          Subclasses should override this method if the menudefinition properties file is in a location other than the default one.
 java.lang.String getPathToResource(java.lang.String resourceName)
          Get the path to the specified named resource which resides in the the resource folder path as specified by the getResourcesPath() method.
 java.lang.String getResourcesPath()
          Subclasses should override this method if the resources folder path is in a location other than the default one.
abstract  XalDocument newDocument(java.net.URL url)
          Subclasses should implement this method to return an instance of their custom subclass of XalDocument loaded from the specified URL.
abstract  XalDocument newEmptyDocument()
          Subclasses should implement this method to return an instance of their custom subclass of XalDocument.
abstract  java.lang.String[] readableDocumentTypes()
          Subclasses should implement this method to return the array of file suffixes identifying the files that can be read by the application.
protected static void setOptions(java.lang.String[] args)
          Define some flags for launching the application, such as pre-load a default accelerator.
 boolean usesConsole()
          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.
abstract  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 application.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

docURLs

public static java.net.URL[] docURLs
The URLs to open existing document(s) in the command-line.

Constructor Detail

ApplicationAdaptor

public ApplicationAdaptor()
Method Detail

readableDocumentTypes

public abstract java.lang.String[] 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

public abstract 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 application.

Returns:
An array of file suffixes corresponding to writable files

newEmptyDocument

public abstract XalDocument newEmptyDocument()
Subclasses should implement this method to return an instance of their custom subclass of XalDocument.

Returns:
An instance of the custom subclass of XalDocument

newDocument

public abstract XalDocument newDocument(java.net.URL url)
Subclasses should implement this method to return an instance of their custom subclass of XalDocument loaded from the specified URL.

Returns:
An instance of the custom subclass of XalDocument

editPreferences

public void editPreferences(XalDocument document)
Override this method to show your application's preference panel. The preference panel may optionally be document specific or application wide depending on the application's specific implementation. The default implementaion displays a warning dialog box that now preference panel exists.

Parameters:
document - The document whose preferences are being changed. Subclass may ignore.

applicationName

public abstract java.lang.String applicationName()
Subclasses must implement this method to return the name of their application.

Returns:
The name of the application

usesConsole

public boolean usesConsole()
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.

Returns:
Whether the application's console should capture standard output and error

customizeCommands

protected void customizeCommands(Commander commander)
Override this method to register custom application commands.

Parameters:
commander - The commander with which to register commands.
See Also:
Commander.registerAction(Action)

setOptions

protected static void setOptions(java.lang.String[] args)
Define some flags for launching the application, such as pre-load a default accelerator.


getDocURLs

public static java.net.URL[] getDocURLs()
Returns:
Document URLs

applicationFinishedLaunching

public void applicationFinishedLaunching()
Subclasses may override this method to provide custom handling upon completion of the application having launched. The default implementation does nothing.


documentClosed

public void documentClosed(XalDocument 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 interface ApplicationListener
Parameters:
document - The document that has closed.

documentCreated

public void documentCreated(XalDocument 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 interface ApplicationListener
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 interface ApplicationListener

getResourcesPath

public java.lang.String getResourcesPath()
Subclasses should override this method if the resources folder path is in a location other than the default one. The default file path is a subfolder called resources located within the same folder where the runtime subclass of ApplicationAdaptor resides. Java package path notation is used. For example "gov.sns.apps.Myapp.resources".

Returns:
The resource path in classpath notation

getPathToResource

public final java.lang.String getPathToResource(java.lang.String resourceName)
Get the path to the specified named resource which resides in the the resource folder path as specified by the getResourcesPath() method. For example if the resources path is gov.sns.apps.Myapp.resources and we wish to get the resource path to the menudef.properties file, the resourceName to specify would simply be "menudef" and the method would return "gov.sns.apps.Myapp.resources.menudef".

Parameters:
resourceName - The name of the resource for which to get the path
Returns:
The resource definition properties file path in classpath notation
See Also:
getResourcesPath()

getMenuDefinitionPath

public java.lang.String getMenuDefinitionPath()
Subclasses should override this method if the menudefinition properties file is in a location other than the default one. The default file path is a properties file called "menudef.properties" located in the resources folder. Java package path notation is used. The file's suffix is excluded from the path. For example "gov.sns.apps.Myapp.resources.menudef".

Returns:
The menu definition properties file path in classpath notation

getApplicationInfoPath

public java.lang.String getApplicationInfoPath()
Subclasses should override this method if the application information properties (displayed in the "About" box) file is in a location other than the default one. The default file path is a properties file called "About.properties" located in the resources folder. Java package path notation is used. The file's suffix is excluded from the path. For example "gov.sns.apps.Myapp.resources.About".

Returns:
The application information properties file path in classpath notation

getApplicationHelpPath

public java.lang.String getApplicationHelpPath()
Subclasses should override this method if the application Help file is in a location other than the default one. The default file is an HTML file called "Help.html" located in the resources folder. Standard relative URL notation is used. For example "resources/Help.html".

Returns:
the relative application help path in posix notation