Class AbstractApplicationAdaptor

java.lang.Object
xal.extension.application.AbstractApplicationAdaptor
All Implemented Interfaces:
ApplicationListener
Direct Known Subclasses:
ApplicationAdaptor, DesktopApplicationAdaptor

public abstract class AbstractApplicationAdaptor extends Object implements ApplicationListener
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 Details

    • WILDCARD_FILE_EXTENSION

      public static final String WILDCARD_FILE_EXTENSION
      wildcard file extension
      See Also:
    • GUI_BRICKS_RESOURCE

      public static final String GUI_BRICKS_RESOURCE
      name for the gui bricks resource which may or may not exist
      See Also:
    • docURLs

      protected static URL[] docURLs
      The URLs to open existing document(s) in the command-line.
  • Constructor Details

    • AbstractApplicationAdaptor

      protected AbstractApplicationAdaptor()
      Constructor
  • Method Details

    • getDefaultDocumentFolder

      public final File getDefaultDocumentFolder()
      Get the default document folder.
      Returns:
      the default folder for documents or null if none has been set.
    • getDefaultDocumentFolderURL

      public final URL 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

      public abstract 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 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
    • 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

      public abstract xal.extension.application.XalAbstractDocument generateEmptyDocument(String type)
      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

      public abstract String applicationName()
      Subclasses must implement this method to return the name of their application.
      Returns:
      The name of the application
    • getUserPreferencesNode

      public final Preferences 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

      public void customizeCommands(Commander commander)
      Override this method to register custom application commands.
      Parameters:
      commander - The commander with which to register commands.
      See Also:
    • setOptions

      public 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 logic
    • getDocURLs

      public static URL[] getDocURLs()
      Get the document URLs.
      Returns:
      document URLs
    • getDefaultWindowReference

      public WindowReference getDefaultWindowReference(String tag, Object... parameters)
      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 interface ApplicationListener
    • 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 interface ApplicationListener
      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 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
    • setResourcesParentDirectory

      public void setResourcesParentDirectory(File resourcesParentDirectory)
      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

      public void setResourcesParentDirectoryWithPath(String resourcesParentDirectoryPath)
      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

      public void setResourcesLocation(URL resourcesLocation)
      Subclasses can set the location of the resources directory. Setting it to null will use the default resource manager.
    • getResourceURL

      public URL getResourceURL(String resourceSpec)
      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